|
|||||||||||
| 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 | |
static String |
CDATA_CONTINUE
To insert ]]> in a CDATA section by ending the last CDATA section with ]] and starting the next CDATA section with > |
static String |
CDATA_DELIMITER_CLOSE
The constant "]]>" |
static String |
CDATA_DELIMITER_OPEN
|
static String |
DEFAULT_SAX_SERIALIZER
|
static String |
EMPTYSTRING
|
static String |
ENTITY_AMP
|
static String |
ENTITY_CRLF
|
static String |
ENTITY_GT
|
static String |
ENTITY_LT
|
static String |
ENTITY_QUOT
|
static String |
XML_PREFIX
|
static String |
XMLNS_PREFIX
|
static String |
XMLNS_URI
|
static String |
XMLVERSION10
|
static String |
XMLVERSION11
Define the XML version. |
| Fields inherited from interface org.apache.xml.serializer.SerializationHandler |
HTML_ATTREMPTY, HTML_ATTRURL, NO_BAD_CHARS |
| Constructor Summary | |
SerializerBase()
|
|
| Method Summary | |
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. |
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. |
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. |
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. |
void |
addAttributes(Attributes atts)
Add the given attributes to the currently collected ones. |
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. |
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(String data)
Receive notification of a comment. |
void |
endEntity(String name)
Report the end of an entity. |
void |
entityReference(String name)
Entity reference event. |
void |
error(SAXParseException exc)
|
void |
fatalError(SAXParseException exc)
|
void |
fireEndEntity(String name)
To fire off end entity trace event |
String |
getDoctypePublic()
Returns the previously set value of the value to be used as the public identifier in the document type declaration (DTD). |
String |
getDoctypeSystem()
Returns the previously set value of the value to be used as the system identifier in the document type declaration (DTD). |
String |
getEncoding()
Returns the character encoding to be used in the output document. |
boolean |
getIndent()
|
int |
getIndentAmount()
|
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 |
String |
getNamespaceURI(String qname,
boolean isElement)
Returns the URI of an element or attribute. |
String |
getNamespaceURIFromPrefix(String prefix)
Returns the URI of prefix (if any) |
boolean |
getOmitXMLDeclaration()
|
String |
getPrefix(String namespaceURI)
Returns the prefix currently pointing to the given URI (if any). |
String |
getStandalone()
Gets the XSL standalone attribute |
Transformer |
getTransformer()
Gets the transformer associated with this serializer |
String |
getVersion()
Gets the version of the output format. |
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(). |
void |
notationDecl(String arg0,
String arg1,
String arg2)
|
boolean |
reset()
This method resets the serializer. |
void |
setDoctype(String doctypeSystem,
String doctypePublic)
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties |
void |
setDoctypePublic(String doctypePublic)
Set the value coming from the xsl:output doctype-public stylesheet attribute. |
void |
setDoctypeSystem(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 |
setDTDEntityExpansion(boolean expand)
If set to false the serializer does not expand DTD entities, but leaves them as is, the default value is true. |
void |
setEncoding(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(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(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(String version)
Sets the value coming from the xsl:output version attribute. |
void |
startDocument()
Receive notification of the beginning of a document. |
void |
unparsedEntityDecl(String arg0,
String arg1,
String arg2,
String arg3)
|
void |
warning(SAXParseException exc)
|
| 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 |
addUniqueAttribute, characters, endElement, flushPending, serialize, setCdataSectionElements, setContentHandler, setEscaping, 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.xml.sax.ext.DeclHandler |
attributeDecl, elementDecl, externalEntityDecl, internalEntityDecl |
| Methods inherited from interface org.apache.xml.serializer.Serializer |
getOutputFormat, getOutputStream, getWriter, setOutputFormat, setOutputStream, setWriter |
| Field Detail |
public static final String CDATA_CONTINUE
public static final String CDATA_DELIMITER_CLOSE
public static final String CDATA_DELIMITER_OPEN
public static final String EMPTYSTRING
public static final String ENTITY_AMP
public static final String ENTITY_CRLF
public static final String ENTITY_GT
public static final String ENTITY_LT
public static final String ENTITY_QUOT
public static final String XML_PREFIX
public static final String XMLNS_PREFIX
public static final String XMLNS_URI
public static final String DEFAULT_SAX_SERIALIZER
public static final String XMLVERSION11
public static final String XMLVERSION10
| Constructor Detail |
public SerializerBase()
| Method Detail |
public void comment(String data)
throws SAXException
comment in interface org.apache.xml.serializer.ExtendedLexicalHandlerdata - the comment, but unlike the SAX comment() method this
method takes a String rather than a character array.
SAXExceptionExtendedLexicalHandler#comment(String)public void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlerlocator - 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.
public void addAttribute(String uri,
String localName,
String rawName,
String type,
String value,
boolean XSLAttribute)
throws SAXException
addAttribute in interface org.apache.xml.serializer.ExtendedContentHandleruri - 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
SAXExceptionExtendedContentHandler#addAttribute(String, String, String, String, String)
public boolean addAttributeAlways(String uri,
String localName,
String rawName,
String type,
String value,
boolean XSLAttribute)
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
public void addAttribute(String name,
String value)
addAttribute in interface org.apache.xml.serializer.ExtendedContentHandlername - the attribute's qualified namevalue - the value of the attribute
public void addXSLAttribute(String name,
String value,
String uri)
addXSLAttribute in interface org.apache.xml.serializer.ExtendedContentHandlername - the attribute's qualified name (prefix:localName)value - the value of the attributeuri - the URI that the prefix of the name points to
public void addAttributes(Attributes atts)
throws SAXException
addAttributes in interface org.apache.xml.serializer.ExtendedContentHandleratts - List of attributes to add to this list
SAXException
public ContentHandler asContentHandler()
throws IOException
ContentHandler interface into this serializer.
If the serializer does not support the ContentHandler
interface, it should return null.
asContentHandler in interface SerializerContentHandler interface into this serializer,
or null if the serializer is not SAX 2 capable
IOException - An I/O exception occured
public void endEntity(String name)
throws SAXException
endEntity in interface LexicalHandlername - 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 SerializationHandlerToStreampublic String getEncoding()
getEncoding in interface org.apache.xml.serializer.XSLOutputAttributespublic void setEncoding(String m_encoding)
setEncoding in interface org.apache.xml.serializer.XSLOutputAttributesm_encoding - the character encodingpublic void setOmitXMLDeclaration(boolean b)
setOmitXMLDeclaration in interface org.apache.xml.serializer.XSLOutputAttributesb - true if the XML declaration is to be omitted from the output
document.public boolean getOmitXMLDeclaration()
getOmitXMLDeclaration in interface org.apache.xml.serializer.XSLOutputAttributespublic String getDoctypePublic()
getDoctypePublic in interface org.apache.xml.serializer.XSLOutputAttributespublic void setDoctypePublic(String doctypePublic)
setDoctypePublic in interface org.apache.xml.serializer.XSLOutputAttributesdoctypePublic - the public identifier to be used in the DOCTYPE
declaration in the output document.public String getDoctypeSystem()
getDoctypeSystem in interface org.apache.xml.serializer.XSLOutputAttributespublic void setDoctypeSystem(String doctypeSystem)
setDoctypeSystem in interface org.apache.xml.serializer.XSLOutputAttributesdoctypeSystem - the system identifier to be used in the DOCTYPE
declaration in the output document.
public void setDoctype(String doctypeSystem,
String doctypePublic)
setDoctype in interface org.apache.xml.serializer.XSLOutputAttributesdoctypeSystem - 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(String standalone)
setStandalone in interface org.apache.xml.serializer.XSLOutputAttributesstandalone - 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 String getStandalone()
getStandalone in interface org.apache.xml.serializer.XSLOutputAttributesstandalone delaration is to
be included in the output document.XSLOutputAttributes#getStandalone()public boolean getIndent()
getIndent in interface org.apache.xml.serializer.XSLOutputAttributespublic String getMediaType()
getMediaType in interface org.apache.xml.serializer.XSLOutputAttributespublic String getVersion()
getVersion in interface org.apache.xml.serializer.XSLOutputAttributespublic void setVersion(String version)
setVersion in interface org.apache.xml.serializer.XSLOutputAttributesversion - the version of the output format.XSLOutputAttributes.setVersion(String)public void setMediaType(String mediaType)
setMediaType in interface org.apache.xml.serializer.XSLOutputAttributesmediaType - 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 org.apache.xml.serializer.XSLOutputAttributespublic void setIndentAmount(int m_indentAmount)
setIndentAmount in interface SerializationHandlerm_indentAmount - The m_indentAmount to setpublic void setIndent(boolean doIndent)
setIndent in interface org.apache.xml.serializer.XSLOutputAttributesdoIndent - true if the output document should be indented to
visually indicate its structure.XSLOutputAttributes#setIndent(boolean)
public void namespaceAfterStartElement(String uri,
String prefix)
throws SAXException
namespaceAfterStartElement in interface org.apache.xml.serializer.ExtendedContentHandleruri - the URI of the namespaceprefix - the prefix associated with the given URI.
SAXExceptionExtendedContentHandler#namespaceAfterStartElement(String, String)
public DOMSerializer asDOMSerializer()
throws IOException
DOMSerializer interface into this serializer. If the
serializer does not support the DOMSerializer interface, it should
return null.
asDOMSerializer in interface SerializerDOMSerializer interface into this serializer, or null
if the serializer is not DOM capable
IOException - An I/O exception occuredSerializer.asDOMSerializer()public NamespaceMappings getNamespaceMappings()
getNamespaceMappings in interface org.apache.xml.serializer.ExtendedContentHandlerExtendedContentHandler#getNamespaceMappings()public String getPrefix(String namespaceURI)
getPrefix in interface org.apache.xml.serializer.ExtendedContentHandlernamespaceURI - the uri of the namespace in question
ExtendedContentHandler#getPrefix(String)
public String getNamespaceURI(String qname,
boolean isElement)
getNamespaceURI in interface org.apache.xml.serializer.ExtendedContentHandlerqname - a qualified nameisElement - true if the qualified name is the name of
an element.
public String getNamespaceURIFromPrefix(String prefix)
getNamespaceURIFromPrefix in interface org.apache.xml.serializer.ExtendedContentHandlerprefix - the prefix whose URI is searched for
public void entityReference(String name)
throws SAXException
entityReference in interface org.apache.xml.serializer.ExtendedContentHandlername - Name of entity
SAXExceptionpublic void setTransformer(Transformer t)
setTransformer in interface SerializationHandlert - the transformer associated with this serializer.SerializationHandler.setTransformer(Transformer)public Transformer getTransformer()
getTransformer in interface SerializationHandlerSerializationHandler.getTransformer()
public void characters(Node node)
throws SAXException
characters in interface org.apache.xml.serializer.ExtendedContentHandlernode - the Node to serialize
SAXException
public void error(SAXParseException exc)
throws SAXException
error in interface ErrorHandlerSAXExceptionErrorHandler.error(SAXParseException)
public void fatalError(SAXParseException exc)
throws SAXException
fatalError in interface ErrorHandlerSAXExceptionErrorHandler.fatalError(SAXParseException)
public void warning(SAXParseException exc)
throws SAXException
warning in interface ErrorHandlerSAXExceptionErrorHandler.warning(SAXParseException)
public void fireEndEntity(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 ContentHandlerSAXException - Any SAX exception, possibly
wrapping another exception.
SAXExceptionpublic void setSourceLocator(SourceLocator locator)
setSourceLocator in interface org.apache.xml.serializer.ExtendedContentHandlerlocator - the source locatorExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)public void setNamespaceMappings(NamespaceMappings mappings)
setNamespaceMappings in interface SerializationHandlermappings - NamespaceMappingspublic boolean reset()
Serializer
reset in interface Serializer
public void addAttribute(String uri,
String localName,
String rawName,
String type,
String value)
throws SAXException
addAttribute in interface org.apache.xml.serializer.ExtendedContentHandleruri - 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
SAXExceptionExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public void notationDecl(String arg0,
String arg1,
String arg2)
throws SAXException
notationDecl in interface DTDHandlerSAXExceptionDTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String)
public void unparsedEntityDecl(String arg0,
String arg1,
String arg2,
String arg3)
throws SAXException
unparsedEntityDecl in interface DTDHandlerSAXExceptionDTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)public void setDTDEntityExpansion(boolean expand)
setDTDEntityExpansion in interface SerializationHandlerexpand - true if DTD entities are to be expanded,
false if they are to be left as DTD entity references.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||