Class AbstractTraxSerializerFactory.NamespaceAsAttributes
- java.lang.Object
-
- org.apache.sling.rewriter.impl.components.AbstractTraxSerializerFactory.NamespaceAsAttributes
-
- All Implemented Interfaces:
ContentHandler,LexicalHandler
- Enclosing class:
- AbstractTraxSerializerFactory
public static class AbstractTraxSerializerFactory.NamespaceAsAttributes extends Object implements ContentHandler, LexicalHandler
A pipe that ensures that all namespace prefixes are also present as 'xmlns:' attributes. This used to circumvent Xalan's serialization behaviour which is to ignore namespaces if they're not present as 'xmlns:xxx' attributes.
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentHandlercontentHandlerprotected LexicalHandlerlexicalHandlerprotected org.slf4j.Loggerlogger
-
Constructor Summary
Constructors Constructor Description NamespaceAsAttributes(ContentHandler handler, org.slf4j.Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] c, int start, int len)Receive notification of character data.voidcomment(char[] ch, int start, int len)Report an XML comment anywhere in the document.voidendCDATA()Report the end of a CDATA section.voidendDocument()voidendDTD()Report the end of DTD declarations.voidendElement(String eltUri, String eltLocalName, String eltQName)Receive notification of the end of an element.voidendEntity(String name)Report the end of an entity.voidendPrefixMapping(String prefix)End the scope of a prefix-URI mapping: remove entry from mapping tables.voidignorableWhitespace(char[] c, int start, int len)Receive notification of ignorable whitespace in element content.voidprocessingInstruction(String target, String data)Receive notification of a processing instruction.voidsetDocumentLocator(Locator locator)voidskippedEntity(String name)Receive notification of a skipped entity.voidstartCDATA()Report the start of a CDATA section.voidstartDocument()voidstartDTD(String name, String publicId, String systemId)Report the start of DTD declarations, if any.voidstartElement(String eltUri, String eltLocalName, String eltQName, Attributes attrs)Ensure all namespace declarations are present asxmlns:attributes and add those needed before calling superclass.voidstartEntity(String name)Report the beginning of an entity.voidstartPrefixMapping(String prefix, String uri)Track mappings to be able to addxmlns:attributes instartElement().
-
-
-
Field Detail
-
contentHandler
protected final ContentHandler contentHandler
-
lexicalHandler
protected final LexicalHandler lexicalHandler
-
logger
protected final org.slf4j.Logger logger
-
-
Constructor Detail
-
NamespaceAsAttributes
public NamespaceAsAttributes(ContentHandler handler, org.slf4j.Logger logger)
-
-
Method Detail
-
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
setDocumentLocatorin interfaceContentHandler- See Also:
ContentHandler.setDocumentLocator(org.xml.sax.Locator)
-
characters
public void characters(char[] c, int start, int len) throws SAXExceptionReceive notification of character data.- Specified by:
charactersin interfaceContentHandler- Parameters:
c- The characters from the XML document.start- The start position in the array.len- The number of characters to read from the array.- Throws:
SAXException
-
ignorableWhitespace
public void ignorableWhitespace(char[] c, int start, int len) throws SAXExceptionReceive notification of ignorable whitespace in element content.- Specified by:
ignorableWhitespacein interfaceContentHandler- Parameters:
c- The characters from the XML document.start- The start position in the array.len- The number of characters to read from the array.- Throws:
SAXException
-
processingInstruction
public void processingInstruction(String target, String data) throws SAXException
Receive notification of a processing instruction.- Specified by:
processingInstructionin interfaceContentHandler- Parameters:
target- The processing instruction target.data- The processing instruction data, or null if none was supplied.- Throws:
SAXException
-
skippedEntity
public void skippedEntity(String name) throws SAXException
Receive notification of a skipped entity.- Specified by:
skippedEntityin interfaceContentHandler- Parameters:
name- The name of the skipped entity. If it is a parameter entity, the name will begin with '%'.- Throws:
SAXException
-
startDTD
public void startDTD(String name, String publicId, String systemId) throws SAXException
Report the start of DTD declarations, if any.- Specified by:
startDTDin interfaceLexicalHandler- Parameters:
name- The document type name.publicId- The declared public identifier for the external DTD subset, or null if none was declared.systemId- The declared system identifier for the external DTD subset, or null if none was declared.- Throws:
SAXException
-
endDTD
public void endDTD() throws SAXExceptionReport the end of DTD declarations.- Specified by:
endDTDin interfaceLexicalHandler- Throws:
SAXException
-
startEntity
public void startEntity(String name) throws SAXException
Report the beginning of an entity.- Specified by:
startEntityin interfaceLexicalHandler- Parameters:
name- The name of the entity. If it is a parameter entity, the name will begin with '%'.- Throws:
SAXException
-
endEntity
public void endEntity(String name) throws SAXException
Report the end of an entity.- Specified by:
endEntityin interfaceLexicalHandler- Parameters:
name- The name of the entity that is ending.- Throws:
SAXException
-
startCDATA
public void startCDATA() throws SAXExceptionReport the start of a CDATA section.- Specified by:
startCDATAin interfaceLexicalHandler- Throws:
SAXException
-
endCDATA
public void endCDATA() throws SAXExceptionReport the end of a CDATA section.- Specified by:
endCDATAin interfaceLexicalHandler- Throws:
SAXException
-
comment
public void comment(char[] ch, int start, int len) throws SAXExceptionReport an XML comment anywhere in the document.- Specified by:
commentin interfaceLexicalHandler- Parameters:
ch- An array holding the characters in the comment.start- The starting position in the array.len- The number of characters to use from the array.- Throws:
SAXException
-
startDocument
public void startDocument() throws SAXException- Specified by:
startDocumentin interfaceContentHandler- Throws:
SAXException
-
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
Track mappings to be able to addxmlns:attributes instartElement().- Specified by:
startPrefixMappingin interfaceContentHandler- Throws:
SAXException
-
startElement
public void startElement(String eltUri, String eltLocalName, String eltQName, Attributes attrs) throws SAXException
Ensure all namespace declarations are present asxmlns:attributes and add those needed before calling superclass. This is a workaround for a Xalan bug (at least in version 2.0.1) :org.apache.xalan.serialize.SerializerToXMLignoresstart/endPrefixMapping().- Specified by:
startElementin interfaceContentHandler- Throws:
SAXException
-
endElement
public void endElement(String eltUri, String eltLocalName, String eltQName) throws SAXException
Receive notification of the end of an element. Try to restore the element qName.- Specified by:
endElementin interfaceContentHandler- Throws:
SAXException
-
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
End the scope of a prefix-URI mapping: remove entry from mapping tables.- Specified by:
endPrefixMappingin interfaceContentHandler- Throws:
SAXException
-
endDocument
public void endDocument() throws SAXException- Specified by:
endDocumentin interfaceContentHandler- Throws:
SAXException
-
-