| java.lang.Object org.apache.xml.serializer.SerializerBase
All known Subclasses: org.apache.xml.serializer.ToUnknownStream, org.apache.xml.serializer.ToStream, org.apache.xml.serializer.ToSAXHandler,
SerializerBase | abstract public class SerializerBase implements SerializationHandler,SerializerConstants(Code) | | This class acts as a base class for the XML "serializers"
and the stream serializers.
It contains a number of common fields and methods.
|
Method Summary | |
public void | addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) 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. | 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. | public void | addAttribute(String uri, String localName, String rawName, String type, String value) This method adds an attribute the the current element,
but should not be used for an xsl:attribute child. | 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. | public void | addAttributes(Attributes atts) Add the given attributes to the currently collected ones. | 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. | public ContentHandler | asContentHandler() Return a
ContentHandler interface into this serializer. | public DOMSerializer | asDOMSerializer() Return a
DOMSerializer interface into this serializer. | public void | characters(org.w3c.dom.Node node) This method gets the nodes value as a String and uses that String as if
it were an input character notification. | public void | close() Flush and close the underlying java.io.Writer. | public void | comment(String data) Receive notification of a comment. | public void | endEntity(String name) Report the end of an entity. | public void | entityReference(String name) Entity reference event. | public void | error(SAXParseException exc) | public void | fatalError(SAXParseException exc) | protected void | fireCDATAEvent(char[] chars, int start, int length) | protected void | fireCharEvent(char[] chars, int start, int length) | protected void | fireCommentEvent(char[] chars, int start, int length) | protected void | fireEndDoc() | protected void | fireEndElem(String name) | public void | fireEndEntity(String name) | protected void | fireEntityReference(String name) | protected void | fireEscapingEvent(String name, String data) | protected void | fireStartDoc() | protected void | fireStartElem(String elemName) Report the start element trace event. | protected void | fireStartEntity(String name) | public String | getDoctypePublic() Returns the previously set value of the value to be used as the public
identifier in the document type declaration (DTD). | public String | getDoctypeSystem() Returns the previously set value of the value to be used
as the system identifier in the document type declaration (DTD). | public String | getEncoding() Returns the character encoding to be used in the output document. | public boolean | getIndent() | public int | getIndentAmount() | protected static String | getLocalName(String qname) Returns the local name of a qualified name. | public String | getMediaType() Gets the mediatype the media-type or MIME type associated with the output
document. | public NamespaceMappings | getNamespaceMappings() | public String | getNamespaceURI(String qname, boolean isElement) Returns the URI of an element or attribute. | public String | getNamespaceURIFromPrefix(String prefix) | public boolean | getOmitXMLDeclaration() | public String | getPrefix(String namespaceURI) Returns the prefix currently pointing to the given URI (if any). | final protected static String | getPrefixPart(String qname) Returns the local name of a qualified name. | public String | getStandalone() | public Transformer | getTransformer() | public String | getVersion() Gets the version of the output format. | final boolean | inTemporaryOutputState() Returns true if the serializer is used for temporary output rather than
final output. | protected void | initCDATA() | protected boolean | isCdataSection() Push a boolean state based on if the name of the current element
is found in the list of qnames. | public void | namespaceAfterStartElement(String uri, 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(). | public void | notationDecl(String arg0, String arg1, String arg2) | protected String | patchName(String qname) If at runtime, when the qname of the attribute is
known, another prefix is specified for the attribute, then we can
patch or hack the name with this method. | public boolean | reset() | 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. | public void | setDoctype(String doctypeSystem, String doctypePublic) | public void | setDoctypePublic(String doctypePublic) Set the value coming from the xsl:output doctype-public stylesheet attribute. | public void | setDoctypeSystem(String doctypeSystem) Set the value coming from the xsl:output doctype-system stylesheet attribute. | public void | setDocumentLocator(Locator locator) Receive an object for locating the origin of SAX document events.
Parameters: locator - An object that can return the location of any SAX documentevent.Receive an object for locating the origin of SAX document events.SAX parsers are strongly encouraged (though not absolutelyrequired) to supply a locator: if it does so, it must supplythe locator to the application by invoking this method beforeinvoking any of the other methods in the DocumentHandlerinterface. The locator allows the application to determine the endposition of any document-related event, even if the parser isnot reporting an error. | public void | setEncoding(String m_encoding) Sets the character encoding coming from the xsl:output encoding stylesheet attribute. | public void | setIndent(boolean doIndent) Sets the value coming from the xsl:output indent stylesheet
attribute. | public void | setIndentAmount(int m_indentAmount) Sets the indentation amount. | public void | setMediaType(String mediaType) Sets the value coming from the xsl:output media-type stylesheet attribute. | public void | setNamespaceMappings(NamespaceMappings mappings) Used only by TransformerSnapshotImpl to restore the serialization
to a previous state. | public void | setOmitXMLDeclaration(boolean b) | public void | setSourceLocator(SourceLocator locator) This method is used to set the source locator, which might be used to
generated an error message. | public void | setStandalone(String standalone) Sets the value coming from the xsl:output standalone stylesheet attribute.
Parameters: standalone - a value of "yes" indicates that thestandalone delaration is to be included in the outputdocument. | protected void | setStandaloneInternal(String standalone) Sets the XSL standalone attribute, but does not remember if this is a
default or explicite setting. | public void | setTransformer(Transformer t) | public void | setVersion(String version) Sets the value coming from the xsl:output version attribute. | public void | startDocument() Receive notification of the beginning of a document. | protected void | startDocumentInternal() This method handles what needs to be done at a startDocument() call,
whether from an external caller, or internally called in the
serializer. | public void | unparsedEntityDecl(String arg0, String arg1, String arg2, String arg3) | public void | warning(SAXParseException exc) |
m_attrBuff | protected char[] m_attrBuff(Code) | | A utility buffer for converting Strings passed to
attribute methods to character arrays.
Reusing this buffer means not creating a new character array
everytime and it runs faster.
|
m_attributes | protected AttributesImplSerializer m_attributes(Code) | | All the attributes of the current element, collected from
startPrefixMapping() calls, or addAddtribute() calls, or
from the SAX attributes in a startElement() call.
|
m_cdataSectionElements | protected Vector m_cdataSectionElements(Code) | | Pairs of local names and corresponding URIs of CDATA sections. This list
comes from the cdata-section-elements attribute. Every second one is a
local name, and every other second one is the URI for the local name.
|
m_cdataTagOpen | protected boolean m_cdataTagOpen(Code) | | True if a trailing "]]>" still needs to be written to be
written out. Used to merge adjacent CDATA sections
|
m_charsBuff | protected char[] m_charsBuff(Code) | | A utility buffer for converting Strings passed to
character() methods to character arrays.
Reusing this buffer means not creating a new character array
everytime and it runs faster.
|
m_doIndent | protected boolean m_doIndent(Code) | | Flag to tell if indenting (pretty-printing) is on.
|
m_elemContext | protected ElemContext m_elemContext(Code) | | A reference to "stack frame" corresponding to
the current element. Such a frame is pushed at a startElement()
and popped at an endElement(). This frame contains information about
the element, such as its namespace URI.
|
m_inEntityRef | protected boolean m_inEntityRef(Code) | | Tells if we're in an EntityRef event.
|
m_inExternalDTD | protected boolean m_inExternalDTD(Code) | | This flag is set while receiving events from the external DTD
|
m_indentAmount | protected int m_indentAmount(Code) | | Amount to indent.
|
m_needToCallStartDocument | protected boolean m_needToCallStartDocument(Code) | | true if we still need to call startDocumentInternal()
|
m_needToOutputDocTypeDecl | boolean m_needToOutputDocTypeDecl(Code) | | Flag to tell that we need to add the doctype decl, which we can't do
until the first element is encountered.
|
m_prefixMap | protected NamespaceMappings m_prefixMap(Code) | | Namespace support, that keeps track of currently defined
prefix/uri mappings. As processed elements come and go, so do
the associated mappings for that element.
|
m_standaloneWasSpecified | protected boolean m_standaloneWasSpecified(Code) | | True if standalone was specified.
|
m_tracer | protected SerializerTrace m_tracer(Code) | | Handle for firing generate events. This interface may be implemented
by the referenced transformer object.
|
m_writer | protected java.io.Writer m_writer(Code) | | The writer to send output to. This field is only used in the ToStream
serializers, but exists here just so that the fireStartDoc() and
other fire... methods can flush this writer when tracing.
|
addAttribute | public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException(Code) | | 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.
Parameters: uri - the URI of the attribute Parameters: localName - the local name of the attribute Parameters: rawName - the qualified name of the attribute Parameters: type - the type of the attribute (probably CDATA) Parameters: value - the value of the attribute Parameters: XSLAttribute - true if this attribute is coming from an xsl:attriute element See Also: ExtendedContentHandler.addAttribute(StringStringStringStringString) |
addAttribute | public void addAttribute(String name, String value)(Code) | | Adds the given attribute to the set of collected attributes,
but only if there is a currently open element.
Parameters: name - the attribute's qualified name Parameters: value - the value of the attribute |
addAttributeAlways | public boolean addAttributeAlways(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute)(Code) | | 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.
Parameters: uri - the URI of the attribute Parameters: localName - the local name of the attribute Parameters: rawName - the qualified name of the attribute Parameters: type - the type of the attribute (probably CDATA) Parameters: value - the value of the attribute Parameters: XSLAttribute - 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(Code) | | Add the given attributes to the currently collected ones. These
attributes are always added, regardless of whether on not an element
is currently open.
Parameters: atts - List of attributes to add to this list |
addXSLAttribute | public void addXSLAttribute(String name, String value, String uri)(Code) | | Adds the given xsl:attribute to the set of collected attributes,
but only if there is a currently open element.
Parameters: name - the attribute's qualified name (prefix:localName) Parameters: value - the value of the attribute Parameters: uri - the URI that the prefix of the name points to |
close | public void close()(Code) | | Flush and close the underlying java.io.Writer. This method applies to
ToStream serializers, not ToSAXHandler serializers.
See Also: ToStream |
fireCDATAEvent | protected void fireCDATAEvent(char[] chars, int start, int length) throws org.xml.sax.SAXException(Code) | | Report the CDATA trace event
Parameters: chars - content of CDATA Parameters: start - starting index of characters to output Parameters: length - number of characters to output |
fireCharEvent | protected void fireCharEvent(char[] chars, int start, int length) throws org.xml.sax.SAXException(Code) | | Report the characters trace event
Parameters: chars - content of characters Parameters: start - starting index of characters to output Parameters: length - number of characters to output |
fireCommentEvent | protected void fireCommentEvent(char[] chars, int start, int length) throws org.xml.sax.SAXException(Code) | | Report the comment trace event
Parameters: chars - content of comment Parameters: start - starting index of comment to output Parameters: length - number of characters to output |
fireEntityReference | protected void fireEntityReference(String name) throws org.xml.sax.SAXException(Code) | | To fire off the entity reference trace event
Parameters: name - Name of entity reference |
fireStartElem | protected void fireStartElem(String elemName) throws org.xml.sax.SAXException(Code) | | Report the start element trace event. This trace method needs to be
called just before the attributes are cleared.
Parameters: elemName - the qualified name of the element |
getDoctypePublic | public String getDoctypePublic()(Code) | | Returns the previously set value of the value to be used as the public
identifier in the document type declaration (DTD).
the public identifier to be used in the DOCTYPE declaration in theoutput document. |
getDoctypeSystem | public String getDoctypeSystem()(Code) | | Returns the previously set value of the value to be used
as the system identifier in the document type declaration (DTD).
the system identifier to be used in the DOCTYPE declaration inthe output document. |
getEncoding | public String getEncoding()(Code) | | Returns the character encoding to be used in the output document.
the character encoding to be used in the output document. |
getIndent | public boolean getIndent()(Code) | | true if the output document should be indented to visuallyindicate its structure. |
getIndentAmount | public int getIndentAmount()(Code) | | the number of spaces to indent for each indentation level. |
getLocalName | protected static String getLocalName(String qname)(Code) | | Returns the local name of a qualified name. If the name has no prefix,
then it works as the identity (SAX2).
Parameters: qname - the qualified name the name, but excluding any prefix and colon. |
getMediaType | public String getMediaType()(Code) | | Gets the mediatype the media-type or MIME type associated with the output
document.
the mediatype the media-type or MIME type associated with theoutput document. |
getNamespaceURI | public String getNamespaceURI(String qname, boolean isElement)(Code) | | Returns the URI of an element or attribute. Note that default namespaces
do not apply directly to attributes.
Parameters: qname - a qualified name Parameters: isElement - 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)(Code) | | Returns the URI of prefix (if any)
Parameters: prefix - the prefix whose URI is searched for the namespace URI currently associated with theprefix, null if the prefix is undefined. |
getOmitXMLDeclaration | public boolean getOmitXMLDeclaration()(Code) | | true if the XML declaration is to be omitted from the outputdocument. |
getPrefixPart | final protected static String getPrefixPart(String qname)(Code) | | Returns the local name of a qualified name.
If the name has no prefix,
then it works as the identity (SAX2).
Parameters: qname - a qualified name returns the prefix of the qualified name,or null if there is no prefix. |
getVersion | public String getVersion()(Code) | | Gets the version of the output format.
the version of the output format. |
inTemporaryOutputState | final boolean inTemporaryOutputState()(Code) | | Returns true if the serializer is used for temporary output rather than
final output.
This concept is made clear in the XSLT 2.0 draft.
|
initCDATA | protected void initCDATA()(Code) | | Initialize global variables
|
isCdataSection | protected boolean isCdataSection()(Code) | | Push a boolean state based on if the name of the current element
is found in the list of qnames. A state is only pushed if
there were some cdata-section-names were specified.
Hidden parameters are the vector of qualified elements specified in
cdata-section-names attribute, and the m_cdataSectionStates stack
onto which whether the current element is in the list is pushed (true or
false). Other hidden parameters are the current elements namespaceURI,
localName and qName
|
namespaceAfterStartElement | public void namespaceAfterStartElement(String uri, String prefix) throws SAXException(Code) | | 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.
Parameters: uri - the URI of the namespace Parameters: prefix - the prefix associated with the given URI. See Also: ExtendedContentHandler.namespaceAfterStartElement(StringString) |
patchName | protected String patchName(String qname)(Code) | | If at runtime, when the qname of the attribute is
known, another prefix is specified for the attribute, then we can
patch or hack the name with this method. For
a qname of the form "ns?:otherprefix:name", this function patches the
qname by simply ignoring "otherprefix".
TODO: This method is a HACK! We do not have access to the
XML file, it sometimes generates a NS prefix of the form "ns?" for
an attribute.
|
reset | public boolean reset()(Code) | | |
setDTDEntityExpansion | public void setDTDEntityExpansion(boolean expand)(Code) | | If set to false the serializer does not expand DTD entities,
but leaves them as is, the default value is true.
|
setDoctype | public void setDoctype(String doctypeSystem, String doctypePublic)(Code) | | Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
Parameters: doctypeSystem - the system identifier to be used in the DOCTYPEdeclaration in the output document. Parameters: doctypePublic - the public identifier to be used in the DOCTYPEdeclaration in the output document. |
setDoctypePublic | public void setDoctypePublic(String doctypePublic)(Code) | | Set the value coming from the xsl:output doctype-public stylesheet attribute.
Parameters: doctypePublic - the public identifier to be used in the DOCTYPEdeclaration in the output document. |
setDoctypeSystem | public void setDoctypeSystem(String doctypeSystem)(Code) | | Set the value coming from the xsl:output doctype-system stylesheet attribute.
Parameters: doctypeSystem - the system identifier to be used in the DOCTYPEdeclaration in the output document. |
setDocumentLocator | public void setDocumentLocator(Locator locator)(Code) | | Receive an object for locating the origin of SAX document events.
Parameters: locator - An object that can return the location of any SAX documentevent.Receive an object for locating the origin of SAX document events.SAX parsers are strongly encouraged (though not absolutelyrequired) to supply a locator: if it does so, it must supplythe locator to the application by invoking this method beforeinvoking any of the other methods in the DocumentHandlerinterface. The locator allows the application to determine the endposition of any document-related event, even if the parser isnot reporting an error. Typically, the application willuse this information for reporting its own errors (such ascharacter content that does not match an application'sbusiness rules). The information returned by the locatoris probably not sufficient for use with a search engine. Note that the locator will return correct information onlyduring the invocation of the events in this interface. Theapplication should not attempt to use it at any other time. |
setEncoding | public void setEncoding(String m_encoding)(Code) | | Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
Parameters: m_encoding - the character encoding |
setIndent | public void setIndent(boolean doIndent)(Code) | | Sets the value coming from the xsl:output indent stylesheet
attribute.
Parameters: doIndent - true if the output document should be indented tovisually indicate its structure. See Also: XSLOutputAttributes.setIndent(boolean) |
setIndentAmount | public void setIndentAmount(int m_indentAmount)(Code) | | Sets the indentation amount.
Parameters: m_indentAmount - The m_indentAmount to set |
setNamespaceMappings | public void setNamespaceMappings(NamespaceMappings mappings)(Code) | | Used only by TransformerSnapshotImpl to restore the serialization
to a previous state.
Parameters: mappings - NamespaceMappings |
setOmitXMLDeclaration | public void setOmitXMLDeclaration(boolean b)(Code) | | Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
Parameters: b - true if the XML declaration is to be omitted from the outputdocument. |
setStandalone | public void setStandalone(String standalone)(Code) | | Sets the value coming from the xsl:output standalone stylesheet attribute.
Parameters: standalone - a value of "yes" indicates that thestandalone delaration is to be included in the outputdocument. This method remembers if the value was explicitly set usingthis method, verses if the value is the default value. |
setStandaloneInternal | protected void setStandaloneInternal(String standalone)(Code) | | Sets the XSL standalone attribute, but does not remember if this is a
default or explicite setting.
Parameters: standalone - "yes" | "no" |
startDocument | public void startDocument() throws org.xml.sax.SAXException(Code) | | 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).
throws: org.xml.sax.SAXException - Any SAX exception, possiblywrapping another exception. throws: org.xml.sax.SAXException - |
startDocumentInternal | protected void startDocumentInternal() throws org.xml.sax.SAXException(Code) | | This method handles what needs to be done at a startDocument() call,
whether from an external caller, or internally called in the
serializer. For historical reasons the serializer is flexible to
startDocument() not always being called.
Even if no external call is
made into startDocument() this method will always be called as a self
generated internal startDocument, it handles what needs to be done at a
startDocument() call.
This method exists just to make sure that startDocument() is only ever
called from an external caller, which in principle is just a matter of
style.
throws: SAXException - |
|
|