This class acts as a base class for the XML "serializers"
and the stream serializers.
It contains a number of common fields and methods.
addAttribute
public void addAttribute(String name,
String value)
Adds the given attribute to the set of collected attributes,
but only if there is a currently open element.
- addAttribute in interface org.apache.xml.serializer.ExtendedContentHandler
name
- the attribute's qualified namevalue
- the value of the attribute
addAttribute
public void addAttribute(String uri,
String localName,
String rawName,
String type,
String value)
throws SAXException
This method adds an attribute the the current element,
but should not be used for an xsl:attribute child.
- addAttribute in interface org.apache.xml.serializer.ExtendedContentHandler
ExtendedContentHandler.addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
addAttribute
public void addAttribute(String uri,
String localName,
String rawName,
String type,
String value,
boolean XSLAttribute)
throws SAXException
Adds the given attribute to the set of collected attributes , but only if
there is a currently open element.
An element is currently open if a startElement() notification has
occured but the start of the element has not yet been written to the
output. In the stream case this means that we have not yet been forced
to close the elements opening tag by another notification, such as a
character notification.
- addAttribute in interface org.apache.xml.serializer.ExtendedContentHandler
uri
- the URI of the attributelocalName
- the local name of the attributerawName
- the qualified name of the attributetype
- the type of the attribute (probably CDATA)value
- the value of the attributeXSLAttribute
- true if this attribute is coming from an xsl:attriute element
ExtendedContentHandler.addAttribute(String, String, String, String, String)
addAttributeAlways
public boolean addAttributeAlways(String uri,
String localName,
String rawName,
String type,
String value,
boolean XSLAttribute)
Adds the given attribute to the set of attributes, even if there is
no currently open element. This is useful if a SAX startPrefixMapping()
should need to add an attribute before the element name is seen.
uri
- the URI of the attributelocalName
- the local name of the attributerawName
- the qualified name of the attributetype
- the type of the attribute (probably CDATA)value
- the value of the attributeXSLAttribute
- true if this attribute is coming from an xsl:attribute element
- true if the attribute was added,
false if an existing value was replaced.
addAttributes
public void addAttributes(Attributes atts)
throws SAXException
Add the given attributes to the currently collected ones. These
attributes are always added, regardless of whether on not an element
is currently open.
atts
- List of attributes to add to this list
addXSLAttribute
public void addXSLAttribute(String name,
String value,
String uri)
Adds the given xsl:attribute to the set of collected attributes,
but only if there is a currently open element.
- addXSLAttribute in interface org.apache.xml.serializer.ExtendedContentHandler
name
- the attribute's qualified name (prefix:localName)value
- the value of the attributeuri
- the URI that the prefix of the name points to
asContentHandler
public ContentHandler asContentHandler()
throws IOException
Return a ContentHandler
interface into this serializer.
If the serializer does not support the ContentHandler
interface, it should return null.
- asContentHandler in interface Serializer
- A
ContentHandler
interface into this serializer,
or null if the serializer is not SAX 2 capable
characters
public void characters(org.w3c.dom.Node node)
throws org.xml.sax.SAXException
This method gets the nodes value as a String and uses that String as if
it were an input character notification.
- characters in interface org.apache.xml.serializer.ExtendedContentHandler
node
- the Node to serialize
close
public void close()
Flush and close the underlying java.io.Writer. This method applies to
ToStream serializers, not ToSAXHandler serializers.
- close in interface SerializationHandler
comment
public void comment(String data)
throws SAXException
Receive notification of a comment.
- comment in interface org.apache.xml.serializer.ExtendedLexicalHandler
ExtendedLexicalHandler.comment(String)
endEntity
public void endEntity(String name)
throws org.xml.sax.SAXException
Report the end of an entity.
name
- The name of the entity that is ending.
entityReference
public void entityReference(String name)
throws org.xml.sax.SAXException
Entity reference event.
- entityReference in interface org.apache.xml.serializer.ExtendedContentHandler
error
public void error(SAXParseException exc)
throws SAXException
org.xml.sax.ErrorHandler.error(SAXParseException)
fatalError
public void fatalError(SAXParseException exc)
throws SAXException
org.xml.sax.ErrorHandler.fatalError(SAXParseException)
fireEndEntity
public void fireEndEntity(String name)
throws org.xml.sax.SAXException
To fire off end entity trace event
getDoctypePublic
public String getDoctypePublic()
Returns the previously set value of the value to be used as the public
identifier in the document type declaration (DTD).
- getDoctypePublic in interface org.apache.xml.serializer.XSLOutputAttributes
- the public identifier to be used in the DOCTYPE declaration in the
output document.
getDoctypeSystem
public String getDoctypeSystem()
Returns the previously set value of the value to be used
as the system identifier in the document type declaration (DTD).
- getDoctypeSystem in interface org.apache.xml.serializer.XSLOutputAttributes
- the system identifier to be used in the DOCTYPE declaration in
the output document.
getEncoding
public String getEncoding()
Returns the character encoding to be used in the output document.
- getEncoding in interface org.apache.xml.serializer.XSLOutputAttributes
- the character encoding to be used in the output document.
getIndent
public boolean getIndent()
- getIndent in interface org.apache.xml.serializer.XSLOutputAttributes
- true if the output document should be indented to visually
indicate its structure.
getIndentAmount
public int getIndentAmount()
- getIndentAmount in interface org.apache.xml.serializer.XSLOutputAttributes
- the number of spaces to indent for each indentation level.
getMediaType
public String getMediaType()
Gets the mediatype the media-type or MIME type associated with the output
document.
- getMediaType in interface org.apache.xml.serializer.XSLOutputAttributes
- the mediatype the media-type or MIME type associated with the
output document.
getNamespaceMappings
public NamespaceMappings getNamespaceMappings()
Some users of the serializer may need the current namespace mappings
- getNamespaceMappings in interface org.apache.xml.serializer.ExtendedContentHandler
- the current namespace mappings (prefix/uri)
ExtendedContentHandler.getNamespaceMappings()
getNamespaceURI
public String getNamespaceURI(String qname,
boolean isElement)
Returns the URI of an element or attribute. Note that default namespaces
do not apply directly to attributes.
- getNamespaceURI in interface org.apache.xml.serializer.ExtendedContentHandler
qname
- a qualified nameisElement
- true if the qualified name is the name of
an element.
- returns the namespace URI associated with the qualified name.
getNamespaceURIFromPrefix
public String getNamespaceURIFromPrefix(String prefix)
Returns the URI of prefix (if any)
- getNamespaceURIFromPrefix in interface org.apache.xml.serializer.ExtendedContentHandler
prefix
- the prefix whose URI is searched for
- the namespace URI currently associated with the
prefix, null if the prefix is undefined.
getOmitXMLDeclaration
public boolean getOmitXMLDeclaration()
- getOmitXMLDeclaration in interface org.apache.xml.serializer.XSLOutputAttributes
- true if the XML declaration is to be omitted from the output
document.
getPrefix
public String getPrefix(String namespaceURI)
Returns the prefix currently pointing to the given URI (if any).
- getPrefix in interface org.apache.xml.serializer.ExtendedContentHandler
namespaceURI
- the uri of the namespace in question
- a prefix pointing to the given URI (if any).
ExtendedContentHandler.getPrefix(String)
getStandalone
public String getStandalone()
Gets the XSL standalone attribute
- getStandalone in interface org.apache.xml.serializer.XSLOutputAttributes
- a value of "yes" if the
standalone
delaration is to
be included in the output document.
XSLOutputAttributes.getStandalone()
getTransformer
public Transformer getTransformer()
Gets the transformer associated with this serializer
- getTransformer in interface SerializationHandler
- returns the transformer associated with this serializer.
getVersion
public String getVersion()
Gets the version of the output format.
- getVersion in interface org.apache.xml.serializer.XSLOutputAttributes
- the version of the output format.
namespaceAfterStartElement
public void namespaceAfterStartElement(String uri,
String prefix)
throws SAXException
This method is used when a prefix/uri namespace mapping
is indicated after the element was started with a
startElement() and before and endElement().
startPrefixMapping(prefix,uri) would be used before the
startElement() call.
- namespaceAfterStartElement in interface org.apache.xml.serializer.ExtendedContentHandler
uri
- the URI of the namespaceprefix
- the prefix associated with the given URI.
ExtendedContentHandler.namespaceAfterStartElement(String, String)
notationDecl
public void notationDecl(String arg0,
String arg1,
String arg2)
throws SAXException
org.xml.sax.DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
setDTDEntityExpansion
public void setDTDEntityExpansion(boolean expand)
If set to false the serializer does not expand DTD entities,
but leaves them as is, the default value is true.
- setDTDEntityExpansion in interface SerializationHandler
setDoctype
public void setDoctype(String doctypeSystem,
String doctypePublic)
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
- setDoctype in interface org.apache.xml.serializer.XSLOutputAttributes
doctypeSystem
- the system identifier to be used in the DOCTYPE
declaration in the output document.doctypePublic
- the public identifier to be used in the DOCTYPE
declaration in the output document.
setDoctypePublic
public void setDoctypePublic(String doctypePublic)
Set the value coming from the xsl:output doctype-public stylesheet attribute.
- setDoctypePublic in interface org.apache.xml.serializer.XSLOutputAttributes
doctypePublic
- the public identifier to be used in the DOCTYPE
declaration in the output document.
setDoctypeSystem
public void setDoctypeSystem(String doctypeSystem)
Set the value coming from the xsl:output doctype-system stylesheet attribute.
- setDoctypeSystem in interface org.apache.xml.serializer.XSLOutputAttributes
doctypeSystem
- the system identifier to be used in the DOCTYPE
declaration in the output document.
setDocumentLocator
public void setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events.
locator
- An object that can return the location of any SAX document
event.
Receive an object for locating the origin of SAX document events.
SAX parsers are strongly encouraged (though not absolutely
required) to supply a locator: if it does so, it must supply
the locator to the application by invoking this method before
invoking any of the other methods in the DocumentHandler
interface.
The locator allows the application to determine the end
position of any document-related event, even if the parser is
not reporting an error. Typically, the application will
use this information for reporting its own errors (such as
character content that does not match an application's
business rules). The information returned by the locator
is probably not sufficient for use with a search engine.
Note that the locator will return correct information only
during the invocation of the events in this interface. The
application should not attempt to use it at any other time.
setEncoding
public void setEncoding(String m_encoding)
Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
- setEncoding in interface org.apache.xml.serializer.XSLOutputAttributes
m_encoding
- the character encoding
setIndent
public void setIndent(boolean doIndent)
Sets the value coming from the xsl:output indent stylesheet
attribute.
- setIndent in interface org.apache.xml.serializer.XSLOutputAttributes
doIndent
- true if the output document should be indented to
visually indicate its structure.
XSLOutputAttributes.setIndent(boolean)
setIndentAmount
public void setIndentAmount(int m_indentAmount)
Sets the indentation amount.
- setIndentAmount in interface SerializationHandler
m_indentAmount
- The m_indentAmount to set
setMediaType
public void setMediaType(String mediaType)
Sets the value coming from the xsl:output media-type stylesheet attribute.
- setMediaType in interface org.apache.xml.serializer.XSLOutputAttributes
mediaType
- the non-null media-type or MIME type associated with the
output document.
javax.xml.transform.OutputKeys.MEDIA_TYPE
, SerializationHandler.setMediaType(String)
setOmitXMLDeclaration
public void setOmitXMLDeclaration(boolean b)
Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
- setOmitXMLDeclaration in interface org.apache.xml.serializer.XSLOutputAttributes
b
- true if the XML declaration is to be omitted from the output
document.
setSourceLocator
public void setSourceLocator(SourceLocator locator)
This method is used to set the source locator, which might be used to
generated an error message.
- setSourceLocator in interface org.apache.xml.serializer.ExtendedContentHandler
locator
- the source locator
ExtendedContentHandler.setSourceLocator(javax.xml.transform.SourceLocator)
setStandalone
public void setStandalone(String standalone)
Sets the value coming from the xsl:output standalone stylesheet attribute.
- setStandalone in interface org.apache.xml.serializer.XSLOutputAttributes
standalone
- a value of "yes" indicates that the
standalone
delaration is to be included in the output
document. This method remembers if the value was explicitly set using
this method, verses if the value is the default value.
setTransformer
public void setTransformer(Transformer t)
Sets the transformer associated with this serializer
- setTransformer in interface SerializationHandler
t
- the transformer associated with this serializer.
setVersion
public void setVersion(String version)
Sets the value coming from the xsl:output version attribute.
- setVersion in interface org.apache.xml.serializer.XSLOutputAttributes
version
- the version of the output format.
SerializationHandler.setVersion(String)
startDocument
public void startDocument()
throws org.xml.sax.SAXException
Receive notification of the beginning of a document.
This method is never a self generated call,
but only called externally.
The SAX parser will invoke this method only once, before any
other methods in this interface or in DTDHandler (except for
setDocumentLocator).
unparsedEntityDecl
public void unparsedEntityDecl(String arg0,
String arg1,
String arg2,
String arg3)
throws SAXException
org.xml.sax.DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
warning
public void warning(SAXParseException exc)
throws SAXException
org.xml.sax.ErrorHandler.warning(SAXParseException)