Package org.apache.xml.serializer
Interface ExtendedContentHandler
- All Superinterfaces:
ContentHandler
- All Known Subinterfaces:
SerializationHandler
- All Known Implementing Classes:
AdaptiveResultTreeImpl
,EmptySerializer
,SerializerBase
,SimpleResultTreeImpl
,StringValueHandler
,ToHTMLSAXHandler
,ToHTMLStream
,ToSAXHandler
,ToStream
,ToTextSAXHandler
,ToTextStream
,ToUnknownStream
,ToXMLSAXHandler
,ToXMLStream
This interface describes extensions to the SAX ContentHandler interface.
It is intended to be used by a serializer. The methods on this interface will
implement SAX- like behavior. This allows the gradual collection of
information rather than having it all up front. For example the call
startElement(namespaceURI,localName,qName,atts)could be replaced with the calls
startElement(namespaceURI,localName,qName) addAttributes(atts)If there are no attributes the second call can be dropped. If attributes are to be added one at a time with calls to
addAttribute(namespaceURI, localName, qName, type, value)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(String qName, String value) Add an attribute to the current element.void
Add at attribute to the current element, not from an xsl:attribute element.void
addAttribute
(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) Add at attribute to the current elementvoid
addAttributes
(Attributes atts) Add attributes to the current elementvoid
addUniqueAttribute
(String qName, String value, int flags) Add a unique attribute to the current element.void
addXSLAttribute
(String qName, String value, String uri) Add an attribute from an xsl:attribute element.void
characters
(String chars) This method is used to notify of a character event, but passing the data as a character String rather than the standard character array.void
characters
(Node node) This method is used to notify of a character event, but passing the data as a DOM Node rather than the standard character array.void
endElement
(String elemName) This method is used to notify that an element has ended.void
entityReference
(String entityName) Notify of an entity reference.This method returns an object that has the current namespace mappings in effect.getNamespaceURI
(String name, boolean isElement) This method gets the prefix associated with a current element or attribute name.getNamespaceURIFromPrefix
(String prefix) This method returns the namespace URI currently associated with the prefix.This method returns the prefix that currently maps to the given namespace URI.void
namespaceAfterStartElement
(String uri, String prefix) This method is used to notify that a prefix mapping is to start, but after an element is started.void
setSourceLocator
(SourceLocator locator) This method is used to set the source locator, which might be used to generated an error message.void
startElement
(String qName) This method is used to notify of the start of an elementvoid
startElement
(String uri, String localName, String qName) This method is used to notify that an element is starting.boolean
startPrefixMapping
(String prefix, String uri, boolean shouldFlush) This method is used to notify that a prefix maping is to start, which can be for the current element, or for the one to come.Methods inherited from interface org.xml.sax.ContentHandler
characters, declaration, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping
-
Field Details
-
NO_BAD_CHARS
static final int NO_BAD_CHARS- See Also:
-
HTML_ATTREMPTY
static final int HTML_ATTREMPTY- See Also:
-
HTML_ATTRURL
static final int HTML_ATTRURL- See Also:
-
-
Method Details
-
addAttribute
void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException Add at attribute to the current element- Parameters:
uri
- the namespace URI of the attribute namelocalName
- the local name of the attribute (without prefix)rawName
- the qualified name of the attributetype
- the attribute type typically character data (CDATA)value
- the value of the attributeXSLAttribute
- true if the added attribute is coming from an xsl:attribute element- Throws:
SAXException
-
addAttributes
Add attributes to the current element- Parameters:
atts
- the attributes to add.- Throws:
SAXException
-
addAttribute
Add an attribute to the current element. The namespace URI of the attribute will be calculated from the prefix of qName. The local name will be derived from qName and the type will be assumed to be "CDATA".- Parameters:
qName
-value
-
-
characters
This method is used to notify of a character event, but passing the data as a character String rather than the standard character array.- Parameters:
chars
- the character data- Throws:
SAXException
-
characters
This method is used to notify of a character event, but passing the data as a DOM Node rather than the standard character array.- Parameters:
node
- a DOM Node containing text.- Throws:
SAXException
-
endElement
This method is used to notify that an element has ended. Unlike the standard SAX methodendElement(namespaceURI,localName,qName)
only the last parameter is passed. If needed the serializer can derive the localName from the qualified name and derive the namespaceURI from its implementation.- Parameters:
elemName
- the fully qualified element name.- Throws:
SAXException
-
startElement
This method is used to notify that an element is starting. This method is just like the standard SAX methodstartElement(uri,localName,qname,atts)
but without the attributes.- Parameters:
uri
- the namespace URI of the elementlocalName
- the local name (without prefix) of the elementqName
- the qualified name of the element- Throws:
SAXException
-
startElement
This method is used to notify of the start of an element- Parameters:
qName
- the fully qualified name of the element- Throws:
SAXException
-
namespaceAfterStartElement
This method is used to notify that a prefix mapping is to start, but after an element is started. The SAX method callstartPrefixMapping(prefix,uri)
is used just before an element starts and applies to the element to come, not to the current element. This method applies to the current element. For example one could make the calls in this order:startElement("prfx8:elem9") namespaceAfterStartElement("http://namespace8","prfx8")
- Parameters:
uri
- the namespace URI being declaredprefix
- the prefix that maps to the given namespace- Throws:
SAXException
-
startPrefixMapping
This method is used to notify that a prefix maping is to start, which can be for the current element, or for the one to come.- Parameters:
prefix
- the prefix that maps to the given URIuri
- the namespace URI of the given prefixshouldFlush
- if true this call is like the SAX startPrefixMapping(prefix,uri) call and the mapping applies to the element to come. If false the mapping applies to the current element.- Returns:
- boolean false if the prefix mapping was already in effect (in other words we are just re-declaring), true if this is a new, never before seen mapping for the element.
- Throws:
SAXException
-
entityReference
Notify of an entity reference.- Parameters:
entityName
- the name of the entity- Throws:
SAXException
-
getNamespaceMappings
NamespaceMappings getNamespaceMappings()This method returns an object that has the current namespace mappings in effect.- Returns:
- NamespaceMappings an object that has the current namespace mappings in effect.
-
getPrefix
This method returns the prefix that currently maps to the given namespace URI.- Parameters:
uri
- the namespace URI- Returns:
- String the prefix that currently maps to the given URI.
-
getNamespaceURI
This method gets the prefix associated with a current element or attribute name.- Parameters:
name
- the qualified name of an element, or attributeisElement
- true if it is an element name, false if it is an atttribute name- Returns:
- String the namespace URI associated with the element or attribute.
-
getNamespaceURIFromPrefix
This method returns the namespace URI currently associated with the prefix.- Parameters:
prefix
- a prefix of an element or attribute.- Returns:
- String the namespace URI currently associated with the prefix.
-
setSourceLocator
This method is used to set the source locator, which might be used to generated an error message.- Parameters:
locator
- the source locator
-
addUniqueAttribute
Add a unique attribute to the current element. The attribute is guaranteed to be unique here. The serializer can write it out immediately without saving it in a table first. The integer flag contains information about the attribute, which helps the serializer to decide whether a particular processing is needed.- Parameters:
qName
- the fully qualified attribute name.value
- the attribute valueflags
- a bitwise flag- Throws:
SAXException
-
addXSLAttribute
Add an attribute from an xsl:attribute element.- Parameters:
qName
- the qualified attribute name (prefix:localName)value
- the attributes valueuri
- the uri that the prefix of the qName is mapped to.
-
addAttribute
void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException Add at attribute to the current element, not from an xsl:attribute element.- Parameters:
uri
- the namespace URI of the attribute namelocalName
- the local name of the attribute (without prefix)rawName
- the qualified name of the attributetype
- the attribute type typically character data (CDATA)value
- the value of the attribute- Throws:
SAXException
-