|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xml.serializer.SerializerBase
This class acts as a base class for the XML "serializers" and the stream serializers. It contains a number of common fields and methods.
Field Summary |
---|
Fields inherited from interface org.apache.xml.serializer.ExtendedContentHandler |
---|
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS |
Fields inherited from interface org.apache.xml.serializer.SerializerConstants |
---|
BEGCDATA, CDATA_CONTINUE, CDATA_DELIMITER_CLOSE, CDATA_DELIMITER_OPEN, CNTCDATA, DEFAULT_SAX_SERIALIZER, EMPTYSTRING, ENDCDATA, ENTITY_AMP, ENTITY_CRLF, ENTITY_GT, ENTITY_LT, ENTITY_QUOT, XML_PREFIX, XMLNS_PREFIX, XMLNS_URI |
Constructor Summary | |
---|---|
SerializerBase()
|
Method Summary | |
---|---|
void |
addAttribute(java.lang.String name,
java.lang.String value)
Adds the given attribute to the set of collected attributes, but only if there is a currently open element. |
void |
addAttribute(java.lang.String uri,
java.lang.String localName,
java.lang.String rawName,
java.lang.String type,
java.lang.String value)
Adds the given attribute to the set of collected attributes , but only if there is a currently open element. |
void |
addAttributeAlways(java.lang.String uri,
java.lang.String localName,
java.lang.String rawName,
java.lang.String type,
java.lang.String value)
Adds the given attribute to the set of attributes, even if there is no currently open element. |
void |
addAttributes(Attributes atts)
Add the given attributes to the currently collected ones. |
ContentHandler |
asContentHandler()
Return a ContentHandler interface into this serializer.
|
DOMSerializer |
asDOMSerializer()
Return a DOMSerializer interface into this serializer. |
void |
characters(Node node)
This method gets the nodes value as a String and uses that String as if it were an input character notification. |
void |
close()
Flush and close the underlying java.io.Writer. |
void |
comment(java.lang.String data)
Receive notification of a comment. |
void |
endEntity(java.lang.String name)
Report the end of an entity. |
void |
entityReference(java.lang.String name)
Entity reference event. |
void |
error(SAXParseException exc)
Receive notification of a recoverable error. |
void |
fatalError(SAXParseException exc)
Receive notification of a non-recoverable error. |
void |
fireEndEntity(java.lang.String name)
To fire off end entity trace event |
java.lang.String |
getDoctypePublic()
Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD). |
java.lang.String |
getDoctypeSystem()
Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD). |
java.lang.String |
getEncoding()
Returns the character encoding to be used in the output document. |
boolean |
getIndent()
|
int |
getIndentAmount()
|
java.lang.String |
getMediaType()
Gets the mediatype the media-type or MIME type associated with the output document. |
NamespaceMappings |
getNamespaceMappings()
Some users of the serializer may need the current namespace mappings |
java.lang.String |
getNamespaceURI(java.lang.String qname,
boolean isElement)
Returns the URI of an element or attribute. |
java.lang.String |
getNamespaceURIFromPrefix(java.lang.String prefix)
Returns the URI of prefix (if any) |
boolean |
getOmitXMLDeclaration()
|
java.lang.String |
getPrefix(java.lang.String namespaceURI)
Returns the prefix currently pointing to the given URI (if any). |
java.lang.String |
getStandalone()
Gets the XSL standalone attribute |
Transformer |
getTransformer()
Gets the transformer associated with this serializer |
java.lang.String |
getVersion()
Gets the version of the output format. |
void |
namespaceAfterStartElement(java.lang.String uri,
java.lang.String prefix)
This method is used when a prefix/uri namespace mapping is indicated after the element was started with a startElement() and before and endElement(). |
boolean |
reset()
Resets the serializer. |
void |
setDoctype(java.lang.String doctypeSystem,
java.lang.String doctypePublic)
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties |
void |
setDoctypePublic(java.lang.String doctypePublic)
Set the value coming from the xsl:output doctype-public stylesheet attribute. |
void |
setDoctypeSystem(java.lang.String doctypeSystem)
Set the value coming from the xsl:output doctype-system stylesheet attribute. |
void |
setDocumentLocator(Locator locator)
Receive an object for locating the origin of SAX document events. |
void |
setEncoding(java.lang.String m_encoding)
Sets the character encoding coming from the xsl:output encoding stylesheet attribute. |
void |
setIndent(boolean doIndent)
Sets the value coming from the xsl:output indent stylesheet attribute. |
void |
setIndentAmount(int m_indentAmount)
Sets the indentation amount. |
void |
setMediaType(java.lang.String mediaType)
Sets the value coming from the xsl:output media-type stylesheet attribute. |
void |
setNamespaceMappings(NamespaceMappings mappings)
Used only by TransformerSnapshotImpl to restore the serialization to a previous state. |
void |
setOmitXMLDeclaration(boolean b)
Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute |
void |
setSourceLocator(SourceLocator locator)
This method is used to set the source locator, which might be used to generated an error message. |
void |
setStandalone(java.lang.String standalone)
Sets the value coming from the xsl:output standalone stylesheet attribute. |
void |
setTransformer(Transformer t)
Sets the transformer associated with this serializer |
void |
setVersion(java.lang.String version)
Sets the value coming from the xsl:output version attribute. |
void |
startDocument()
Receive notification of the beginning of a document. |
void |
warning(SAXParseException exc)
Receive notification of a warning. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.xml.serializer.SerializationHandler |
---|
flushPending, serialize, setContentHandler, setEscaping |
Methods inherited from interface org.apache.xml.serializer.ExtendedContentHandler |
---|
addUniqueAttribute, characters, endElement, startElement, startElement, startPrefixMapping |
Methods inherited from interface org.xml.sax.ContentHandler |
---|
characters, endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startElement, startPrefixMapping |
Methods inherited from interface org.xml.sax.ext.LexicalHandler |
---|
comment, endCDATA, endDTD, startCDATA, startDTD, startEntity |
Methods inherited from interface org.apache.xml.serializer.XSLOutputAttributes |
---|
setCdataSectionElements |
Methods inherited from interface org.xml.sax.ext.DeclHandler |
---|
attributeDecl, elementDecl, externalEntityDecl, internalEntityDecl |
Methods inherited from interface org.apache.xml.serializer.Serializer |
---|
getOutputFormat, getOutputStream, getWriter, setOutputFormat, setOutputStream, setWriter |
Constructor Detail |
public SerializerBase()
Method Detail |
public void comment(java.lang.String data) throws SAXException
comment
in interface ExtendedLexicalHandler
data
- the comment, but unlike the SAX comment() method this
method takes a String rather than a character array.
SAXException
ExtendedLexicalHandler.comment(String)
public void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
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.
Locator
public void addAttribute(java.lang.String uri, java.lang.String localName, java.lang.String rawName, java.lang.String type, java.lang.String value) throws SAXException
addAttribute
in interface 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 attribute
SAXException
ExtendedContentHandler.addAttribute(String, String, String, String, String)
public void addAttributeAlways(java.lang.String uri, java.lang.String localName, java.lang.String rawName, java.lang.String type, java.lang.String value)
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 attributepublic void addAttribute(java.lang.String name, java.lang.String value)
addAttribute
in interface ExtendedContentHandler
name
- the attribute's qualified namevalue
- the value of the attributepublic void addAttributes(Attributes atts) throws SAXException
addAttributes
in interface ExtendedContentHandler
atts
- List of attributes to add to this list
SAXException
public ContentHandler asContentHandler() throws java.io.IOException
ContentHandler
interface into this serializer.
If the serializer does not support the ContentHandler
interface, it should return null.
asContentHandler
in interface Serializer
ContentHandler
interface into this serializer,
or null if the serializer is not SAX 2 capable
java.io.IOException
- An I/O exception occuredpublic void endEntity(java.lang.String name) throws SAXException
endEntity
in interface LexicalHandler
name
- The name of the entity that is ending.
SAXException
- The application may raise an exception.LexicalHandler.startEntity(java.lang.String)
public void close()
close
in interface SerializationHandler
ToStream
public java.lang.String getEncoding()
getEncoding
in interface XSLOutputAttributes
public void setEncoding(java.lang.String m_encoding)
setEncoding
in interface XSLOutputAttributes
m_encoding
- the character encodingpublic void setOmitXMLDeclaration(boolean b)
setOmitXMLDeclaration
in interface XSLOutputAttributes
b
- true if the XML declaration is to be omitted from the output
document.public boolean getOmitXMLDeclaration()
getOmitXMLDeclaration
in interface XSLOutputAttributes
public java.lang.String getDoctypePublic()
getDoctypePublic
in interface XSLOutputAttributes
public void setDoctypePublic(java.lang.String doctypePublic)
setDoctypePublic
in interface XSLOutputAttributes
doctypePublic
- the public identifier to be used in the DOCTYPE
declaration in the output document.public java.lang.String getDoctypeSystem()
getDoctypeSystem
in interface XSLOutputAttributes
public void setDoctypeSystem(java.lang.String doctypeSystem)
setDoctypeSystem
in interface XSLOutputAttributes
doctypeSystem
- the system identifier to be used in the DOCTYPE
declaration in the output document.public void setDoctype(java.lang.String doctypeSystem, java.lang.String doctypePublic)
setDoctype
in interface 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.public void setStandalone(java.lang.String standalone)
setStandalone
in interface 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.public java.lang.String getStandalone()
getStandalone
in interface XSLOutputAttributes
standalone
delaration is to
be included in the output document.XSLOutputAttributes.getStandalone()
public boolean getIndent()
getIndent
in interface XSLOutputAttributes
public java.lang.String getMediaType()
getMediaType
in interface XSLOutputAttributes
public java.lang.String getVersion()
getVersion
in interface XSLOutputAttributes
public void setVersion(java.lang.String version)
setVersion
in interface XSLOutputAttributes
version
- the version of the output format.XSLOutputAttributes.setVersion(String)
public void setMediaType(java.lang.String mediaType)
setMediaType
in interface XSLOutputAttributes
mediaType
- the non-null media-type or MIME type associated with the
output document.OutputKeys.MEDIA_TYPE
,
XSLOutputAttributes.setMediaType(String)
public int getIndentAmount()
getIndentAmount
in interface XSLOutputAttributes
public void setIndentAmount(int m_indentAmount)
setIndentAmount
in interface SerializationHandler
m_indentAmount
- The m_indentAmount to setpublic void setIndent(boolean doIndent)
setIndent
in interface XSLOutputAttributes
doIndent
- true if the output document should be indented to
visually indicate its structure.XSLOutputAttributes.setIndent(boolean)
public void namespaceAfterStartElement(java.lang.String uri, java.lang.String prefix) throws SAXException
namespaceAfterStartElement
in interface ExtendedContentHandler
uri
- the URI of the namespaceprefix
- the prefix associated with the given URI.
SAXException
ExtendedContentHandler.namespaceAfterStartElement(String, String)
public DOMSerializer asDOMSerializer() throws java.io.IOException
DOMSerializer
interface into this serializer. If the
serializer does not support the DOMSerializer
interface, it should
return null.
asDOMSerializer
in interface Serializer
DOMSerializer
interface into this serializer, or null
if the serializer is not DOM capable
java.io.IOException
- An I/O exception occuredSerializer.asDOMSerializer()
public NamespaceMappings getNamespaceMappings()
getNamespaceMappings
in interface ExtendedContentHandler
ExtendedContentHandler.getNamespaceMappings()
public java.lang.String getPrefix(java.lang.String namespaceURI)
getPrefix
in interface ExtendedContentHandler
namespaceURI
- the uri of the namespace in question
ExtendedContentHandler.getPrefix(String)
public java.lang.String getNamespaceURI(java.lang.String qname, boolean isElement)
getNamespaceURI
in interface ExtendedContentHandler
qname
- a qualified nameisElement
- true if the qualified name is the name of
an element.
public java.lang.String getNamespaceURIFromPrefix(java.lang.String prefix)
getNamespaceURIFromPrefix
in interface ExtendedContentHandler
prefix
- the prefix whose URI is searched for
public void entityReference(java.lang.String name) throws SAXException
entityReference
in interface ExtendedContentHandler
name
- Name of entity
SAXException
public void setTransformer(Transformer t)
setTransformer
in interface SerializationHandler
t
- the transformer associated with this serializer.SerializationHandler.setTransformer(Transformer)
public Transformer getTransformer()
getTransformer
in interface SerializationHandler
SerializationHandler.getTransformer()
public void characters(Node node) throws SAXException
characters
in interface DOM2DTM.CharacterNodeHandler
node
- the Node to serialize
SAXException
public void error(SAXParseException exc) throws SAXException
ErrorHandler
This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML 1.0 recommendation does not require it to do so.
Filters may use this method to report other, non-XML errors as well.
error
in interface ErrorHandler
exc
- The error information encapsulated in a
SAX parse exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.ErrorHandler.error(SAXParseException)
public void fatalError(SAXParseException exc) throws SAXException
ErrorHandler
This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.
The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting addition error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.
fatalError
in interface ErrorHandler
exc
- The error information encapsulated in a
SAX parse exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.ErrorHandler.fatalError(SAXParseException)
public void warning(SAXParseException exc) throws SAXException
ErrorHandler
SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.
Filters may use this method to report other, non-XML warnings as well.
warning
in interface ErrorHandler
exc
- The warning information encapsulated in a
SAX parse exception.
SAXException
- Any SAX exception, possibly
wrapping another exception.ErrorHandler.warning(SAXParseException)
public void fireEndEntity(java.lang.String name) throws SAXException
name
- Name of entity
SAXException
public void startDocument() throws SAXException
The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler (except for setDocumentLocator).
startDocument
in interface ContentHandler
SAXException
- Any SAX exception, possibly
wrapping another exception.
SAXException
ContentHandler.endDocument()
public void setSourceLocator(SourceLocator locator)
setSourceLocator
in interface ExtendedContentHandler
locator
- the source locatorExtendedContentHandler.setSourceLocator(javax.xml.transform.SourceLocator)
public void setNamespaceMappings(NamespaceMappings mappings)
setNamespaceMappings
in interface SerializationHandler
public boolean reset()
Serializer
reset
in interface Serializer
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |