public class EmptySerializer extends Object implements SerializationHandler
| Modifier and Type | Field and Description |
|---|---|
protected static String |
ERR |
static int |
HTML_ATTREMPTY |
static int |
HTML_ATTRURL |
static int |
NO_BAD_CHARS |
| Constructor and Description |
|---|
EmptySerializer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAttribute(String name,
String value)
Add an attribute to the current element.
|
void |
addAttribute(String uri,
String localName,
String rawName,
String type,
String value)
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 element
|
void |
addAttributes(Attributes atts)
Add attributes to the current element
|
void |
addUniqueAttribute(String name,
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.
|
ContentHandler |
asContentHandler()
Return a
ContentHandler interface to provide SAX input to. |
DOMSerializer |
asDOMSerializer()
Return a
DOMSerializer interface into this serializer. |
void |
attributeDecl(String arg0,
String arg1,
String arg2,
String arg3,
String arg4) |
void |
characters(char[] arg0,
int arg1,
int arg2) |
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 |
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 |
close() |
void |
comment(char[] arg0,
int arg1,
int arg2) |
void |
comment(String comment)
This method is used to notify of a comment
|
protected void |
couldThrowException() |
protected void |
couldThrowIOException() |
protected void |
couldThrowSAXException() |
protected void |
couldThrowSAXException(char[] chars,
int off,
int len) |
protected void |
couldThrowSAXException(String elemQName) |
void |
elementDecl(String arg0,
String arg1) |
void |
endCDATA() |
void |
endDocument() |
void |
endDTD() |
void |
endElement(String elemName)
This method is used to notify that an element has ended.
|
void |
endElement(String arg0,
String arg1,
String arg2) |
void |
endEntity(String arg0) |
void |
endPrefixMapping(String arg0) |
void |
entityReference(String entityName)
Notify of an entity reference.
|
void |
error(SAXParseException arg0) |
void |
externalEntityDecl(String arg0,
String arg1,
String arg2) |
void |
fatalError(SAXParseException arg0) |
void |
flushPending()
Flush any pending events currently queued up in the serializer.
|
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() |
boolean |
getIndent() |
int |
getIndentAmount() |
String |
getMediaType() |
NamespaceMappings |
getNamespaceMappings()
This method returns an object that has the current namespace mappings in
effect.
|
String |
getNamespaceURI(String name,
boolean isElement)
This method gets the prefix associated with a current element or
attribute name.
|
String |
getNamespaceURIFromPrefix(String prefix)
This method returns the namespace URI currently associated with the
prefix.
|
boolean |
getOmitXMLDeclaration() |
Properties |
getOutputFormat()
Returns the output format properties for this serializer.
|
OutputStream |
getOutputStream()
Get the output stream where the events will be serialized to.
|
String |
getPrefix(String uri)
This method returns the prefix that currently maps to the given namespace
URI.
|
String |
getStandalone() |
Transformer |
getTransformer()
Get the transformer associated with the serializer.
|
String |
getVersion() |
Writer |
getWriter()
Get the character stream where the events will be serialized to.
|
void |
ignorableWhitespace(char[] arg0,
int arg1,
int arg2) |
void |
internalEntityDecl(String arg0,
String arg1) |
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 |
notationDecl(String arg0,
String arg1,
String arg2) |
void |
processingInstruction(String arg0,
String arg1) |
boolean |
reset()
This method resets the serializer.
|
void |
serialize(Node node)
Notify that the serializer should take this DOM node as input to be
serialized.
|
void |
setCdataSectionElements(Hashtable h) |
void |
setCdataSectionElements(Vector URI_and_localNames)
Sets the value coming from the xsl:output cdata-section-elements
stylesheet property.
|
void |
setContentHandler(ContentHandler ch)
Set the SAX Content handler that the serializer sends its output to.
|
void |
setDoctype(String system,
String pub)
Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
|
void |
setDoctypePublic(String doctype)
Set the value coming from the xsl:output doctype-public stylesheet attribute.
|
void |
setDoctypeSystem(String doctype)
Set the value coming from the xsl:output doctype-system stylesheet attribute.
|
void |
setDocumentLocator(Locator arg0) |
void |
setDTDEntityExpansion(boolean expand)
Default behavior is to expand DTD entities,
that is the initall default value is true.
|
void |
setEncoding(String encoding)
Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
|
boolean |
setEscaping(boolean escape)
Turns special character escaping on/off.
|
void |
setIndent(boolean indent)
Sets the value coming from the xsl:output indent stylesheet
attribute.
|
void |
setIndentAmount(int spaces)
Set the number of spaces to indent for each indentation level.
|
void |
setIsStandalone(boolean isStandalone)
Specify if the output will be treated as a standalone property
|
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 |
setOutputFormat(Properties format)
Specifies an output format for this serializer.
|
void |
setOutputStream(OutputStream output)
Specifies an output stream to which the document should be
serialized.
|
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 transformer)
Set the transformer associated with the serializer.
|
void |
setVersion(String version)
Sets the value coming from the xsl:output version attribute.
|
void |
setWriter(Writer writer)
Specifies a writer to which the document should be serialized.
|
void |
skippedEntity(String arg0) |
void |
startCDATA() |
void |
startDocument() |
void |
startDTD(String arg0,
String arg1,
String arg2) |
void |
startElement(String qName)
This method is used to notify of the start of an element
|
void |
startElement(String uri,
String localName,
String qName)
This method is used to notify that an element is starting.
|
void |
startElement(String arg0,
String arg1,
String arg2,
Attributes arg3) |
void |
startEntity(String arg0) |
void |
startPrefixMapping(String arg0,
String arg1) |
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.
|
void |
unparsedEntityDecl(String arg0,
String arg1,
String arg2,
String arg3) |
void |
warning(SAXParseException arg0) |
protected static final String ERR
public static final int NO_BAD_CHARS
public static final int HTML_ATTREMPTY
public static final int HTML_ATTRURL
protected void couldThrowIOException()
throws IOException
IOExceptionSerializer.asContentHandler()protected void couldThrowSAXException()
throws SAXException
SAXExceptionprotected void couldThrowSAXException(char[] chars,
int off,
int len)
throws SAXException
SAXExceptionprotected void couldThrowSAXException(String elemQName) throws SAXException
SAXExceptionpublic ContentHandler asContentHandler() throws IOException
SerializerContentHandler interface to provide SAX input to.
Through the returned object the document to be serailized,
as a series of SAX events, can be provided to the serialzier.
If the serializer does not support the ContentHandler
interface, it will return null.
In principle only one of asDOMSerializer() or asContentHander() should be called.
asContentHandler in interface SerializerContentHandler interface into this serializer,
or null if the serializer is not SAX 2 capableIOException - An I/O exception occuredSerializer.asContentHandler()public void setContentHandler(ContentHandler ch)
SerializationHandlersetContentHandler in interface SerializationHandlerSerializationHandler.setContentHandler(org.xml.sax.ContentHandler)public void close()
close in interface SerializationHandlerSerializationHandler.close()public Properties getOutputFormat()
SerializergetOutputFormat in interface SerializerSerializer.getOutputFormat()public OutputStream getOutputStream()
SerializergetOutputStream in interface SerializerSerializer.getOutputStream()public Writer getWriter()
SerializergetWriter in interface SerializerSerializer.getWriter()public boolean reset()
Serializerreset in interface SerializerSerializer.reset()public void serialize(Node node) throws IOException
SerializationHandlerserialize in interface DOMSerializerserialize in interface SerializationHandlernode - the DOM node to be serialized.IOException - if an I/O exception occured while serializingSerializationHandler.serialize(org.w3c.dom.Node)public void setCdataSectionElements(Vector URI_and_localNames)
URI_and_localNames - pairs of namespace URI and local names that
identify elements whose text elements are to be output as CDATA sections.
The namespace of the local element must be the given URI to match. The
qName is not given because the prefix does not matter, only the namespace
URI to which that prefix would map matters, so the prefix itself is not
relevant in specifying which elements have their text to be output as
CDATA sections.XSLOutputAttributes.setCdataSectionElements(java.util.Vector)public boolean setEscaping(boolean escape)
throws SAXException
SerializationHandlersetEscaping in interface SerializationHandlerescape - true if escaping is to be set on.SAXExceptionSerializationHandler.setEscaping(boolean)public void setIndent(boolean indent)
indent - true if the output document should be indented to visually
indicate its structure.XSLOutputAttributes.setIndent(boolean)public void setIndentAmount(int spaces)
SerializationHandlersetIndentAmount in interface SerializationHandlerspaces - the number of spaces to indent for each indentation level.SerializationHandler.setIndentAmount(int)public void setIsStandalone(boolean isStandalone)
SerializationHandlersetIsStandalone in interface SerializationHandlerSerializationHandler.setIsStandalone(boolean)public void setOutputFormat(Properties format)
SerializerThe standard property keys supported are: "method", "version", "encoding", "omit-xml-declaration", "standalone", doctype-public", "doctype-system", "cdata-section-elements", "indent", "media-type". These property keys and their values are described in the XSLT recommendation, see XSLT 1.0 recommendation
The non-standard property keys supported are defined in OutputPropertiesFactory.
This method can be called multiple times before a document is serialized. Each time it is called more, or over-riding property values, can be specified. One property value that can not be changed is that of the "method" property key.
The value of the "cdata-section-elements" property key is a whitespace separated list of elements. If the element is in a namespace then value is passed in this format: {uri}localName
If the "cdata-section-elements" key is specified on multiple calls to this method the set of elements specified in the value is not replaced from one call to the next, but it is cumulative across the calls.
setOutputFormat in interface Serializerformat - The output format to use, as a set of key/value pairs.Serializer.setOutputFormat(java.util.Properties)public void setOutputStream(OutputStream output)
Serializer
The encoding specified in the output Properties is used, or
if no encoding was specified, the default for the selected
output method.
Only one of setWriter() or setOutputStream() should be called.
setOutputStream in interface Serializeroutput - The output streamSerializer.setOutputStream(java.io.OutputStream)public void setVersion(String version)
version - the version of the output format.XSLOutputAttributes.setVersion(java.lang.String)public void setWriter(Writer writer)
Serializer
The encoding specified for the output Properties must be
identical to the output format used with the writer.
Only one of setWriter() or setOutputStream() should be called.
setWriter in interface Serializerwriter - The output writer streamSerializer.setWriter(java.io.Writer)public void setTransformer(Transformer transformer)
SerializationHandlersetTransformer in interface SerializationHandlertransformer - the transformer associated with the serializer.SerializationHandler.setTransformer(javax.xml.transform.Transformer)public Transformer getTransformer()
SerializationHandlergetTransformer in interface SerializationHandlerSerializationHandler.getTransformer()public void flushPending()
throws SAXException
SerializationHandlerflushPending in interface SerializationHandlerSAXExceptionSerializationHandler.flushPending()public void addAttribute(String uri, String localName, String rawName, String type, String value, boolean XSLAttribute) throws SAXException
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 elementSAXExceptionExtendedContentHandler.addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)public void addAttributes(Attributes atts) throws SAXException
atts - the attributes to add.SAXExceptionExtendedContentHandler.addAttributes(org.xml.sax.Attributes)public void addAttribute(String name, String value)
ExtendedContentHandler.addAttribute(java.lang.String, java.lang.String)public void characters(String chars) throws SAXException
chars - the character dataSAXExceptionExtendedContentHandler.characters(java.lang.String)public void endElement(String elemName) throws SAXException
endElement(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.
elemName - the fully qualified element name.SAXExceptionExtendedContentHandler.endElement(java.lang.String)public void startDocument()
throws SAXException
SAXExceptionContentHandler.startDocument()public void startElement(String uri, String localName, String qName) throws SAXException
startElement(uri,localName,qname,atts)but without the attributes.
uri - the namespace URI of the elementlocalName - the local name (without prefix) of the elementqName - the qualified name of the elementSAXExceptionExtendedContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String)public void startElement(String qName) throws SAXException
qName - the fully qualified name of the elementSAXExceptionExtendedContentHandler.startElement(java.lang.String)public void namespaceAfterStartElement(String uri, String prefix) throws SAXException
startPrefixMapping(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")
uri - the namespace URI being declaredprefix - the prefix that maps to the given namespaceSAXExceptionExtendedContentHandler.namespaceAfterStartElement(java.lang.String, java.lang.String)public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush) throws SAXException
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.SAXExceptionExtendedContentHandler.startPrefixMapping(java.lang.String, java.lang.String, boolean)public void entityReference(String entityName) throws SAXException
entityName - the name of the entitySAXExceptionExtendedContentHandler.entityReference(java.lang.String)public NamespaceMappings getNamespaceMappings()
ExtendedContentHandler.getNamespaceMappings()public String getPrefix(String uri)
uri - the namespace URIExtendedContentHandler.getPrefix(java.lang.String)public String getNamespaceURI(String name, boolean isElement)
name - the qualified name of an element, or attributeisElement - true if it is an element name, false if it is an
atttribute nameExtendedContentHandler.getNamespaceURI(java.lang.String, boolean)public String getNamespaceURIFromPrefix(String prefix)
prefix - a prefix of an element or attribute.ExtendedContentHandler.getNamespaceURIFromPrefix(java.lang.String)public void setDocumentLocator(Locator arg0)
public void endDocument()
throws SAXException
SAXExceptionContentHandler.endDocument()public void startPrefixMapping(String arg0, String arg1) throws SAXException
public void endPrefixMapping(String arg0) throws SAXException
SAXExceptionContentHandler.endPrefixMapping(java.lang.String)public void startElement(String arg0, String arg1, String arg2, Attributes arg3) throws SAXException
public void endElement(String arg0, String arg1, String arg2) throws SAXException
public void characters(char[] arg0,
int arg1,
int arg2)
throws SAXException
SAXExceptionContentHandler.characters(char[], int, int)public void ignorableWhitespace(char[] arg0,
int arg1,
int arg2)
throws SAXException
SAXExceptionContentHandler.ignorableWhitespace(char[], int, int)public void processingInstruction(String arg0, String arg1) throws SAXException
public void skippedEntity(String arg0) throws SAXException
SAXExceptionContentHandler.skippedEntity(java.lang.String)public void comment(String comment) throws SAXException
comment - the comment, but unlike the SAX comment() method this
method takes a String rather than a character array.SAXExceptionExtendedLexicalHandler.comment(java.lang.String)public void startDTD(String arg0, String arg1, String arg2) throws SAXException
public void endDTD()
throws SAXException
SAXExceptionLexicalHandler.endDTD()public void startEntity(String arg0) throws SAXException
SAXExceptionLexicalHandler.startEntity(java.lang.String)public void endEntity(String arg0) throws SAXException
SAXExceptionLexicalHandler.endEntity(java.lang.String)public void startCDATA()
throws SAXException
SAXExceptionLexicalHandler.startCDATA()public void endCDATA()
throws SAXException
SAXExceptionLexicalHandler.endCDATA()public void comment(char[] arg0,
int arg1,
int arg2)
throws SAXException
SAXExceptionLexicalHandler.comment(char[], int, int)public String getDoctypePublic()
XSLOutputAttributes.getDoctypePublic()public String getDoctypeSystem()
XSLOutputAttributes.getDoctypeSystem()public String getEncoding()
XSLOutputAttributes.getEncoding()public boolean getIndent()
XSLOutputAttributes.getIndent()public int getIndentAmount()
XSLOutputAttributes.getIndentAmount()public String getMediaType()
XSLOutputAttributes.getMediaType()public boolean getOmitXMLDeclaration()
XSLOutputAttributes.getOmitXMLDeclaration()public String getStandalone()
standalone delaration is to
be included in the output document.XSLOutputAttributes.getStandalone()public String getVersion()
XSLOutputAttributes.getVersion()public void setCdataSectionElements(Hashtable h) throws Exception
ExceptionXSLOutputAttributes.setCdataSectionElements(java.util.Vector)public void setDoctype(String system, String pub)
system - the system identifier to be used in the DOCTYPE declaration
in the output document.pub - the public identifier to be used in the DOCTYPE declaration in
the output document.XSLOutputAttributes.setDoctype(java.lang.String, java.lang.String)public void setDoctypePublic(String doctype)
doctype - the public identifier to be used in the DOCTYPE
declaration in the output document.XSLOutputAttributes.setDoctypePublic(java.lang.String)public void setDoctypeSystem(String doctype)
doctype - the system identifier to be used in the DOCTYPE
declaration in the output document.XSLOutputAttributes.setDoctypeSystem(java.lang.String)public void setEncoding(String encoding)
encoding - the character encodingXSLOutputAttributes.setEncoding(java.lang.String)public void setMediaType(String mediatype)
mediatype - the media-type or MIME type associated with the output
document.XSLOutputAttributes.setMediaType(java.lang.String)public void setOmitXMLDeclaration(boolean b)
b - true if the XML declaration is to be omitted from the output
document.XSLOutputAttributes.setOmitXMLDeclaration(boolean)public void setStandalone(String standalone)
standalone - a value of "yes" indicates that the
standalone delaration is to be included in the output
document.XSLOutputAttributes.setStandalone(java.lang.String)public void elementDecl(String arg0, String arg1) throws SAXException
elementDecl in interface DeclHandlerSAXExceptionDeclHandler.elementDecl(java.lang.String, java.lang.String)public void attributeDecl(String arg0, String arg1, String arg2, String arg3, String arg4) throws SAXException
attributeDecl in interface DeclHandlerSAXExceptionDeclHandler.attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)public void internalEntityDecl(String arg0, String arg1) throws SAXException
internalEntityDecl in interface DeclHandlerSAXExceptionDeclHandler.internalEntityDecl(java.lang.String, java.lang.String)public void externalEntityDecl(String arg0, String arg1, String arg2) throws SAXException
externalEntityDecl in interface DeclHandlerSAXExceptionDeclHandler.externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)public void warning(SAXParseException arg0) throws SAXException
warning in interface ErrorHandlerSAXExceptionErrorHandler.warning(org.xml.sax.SAXParseException)public void error(SAXParseException arg0) throws SAXException
error in interface ErrorHandlerSAXExceptionErrorHandler.error(org.xml.sax.SAXParseException)public void fatalError(SAXParseException arg0) throws SAXException
fatalError in interface ErrorHandlerSAXExceptionErrorHandler.fatalError(org.xml.sax.SAXParseException)public DOMSerializer asDOMSerializer() throws IOException
SerializerDOMSerializer interface into this serializer.
Through the returned object the document to be serialized,
a DOM, can be provided to the serializer.
If the serializer does not support the DOMSerializer
interface, it should return null.
In principle only one of asDOMSerializer() or asContentHander() should be called.
asDOMSerializer in interface SerializerDOMSerializer interface into this serializer,
or null if the serializer is not DOM capableIOException - An I/O exception occuredSerializer.asDOMSerializer()public void setNamespaceMappings(NamespaceMappings mappings)
SerializationHandlersetNamespaceMappings in interface SerializationHandlermappings - NamespaceMappingsSerializationHandler.setNamespaceMappings(NamespaceMappings)public void setSourceLocator(SourceLocator locator)
locator - the source locatorExtendedContentHandler.setSourceLocator(javax.xml.transform.SourceLocator)public void addUniqueAttribute(String name, String value, int flags) throws SAXException
name - the fully qualified attribute name.value - the attribute valueflags - a bitwise flagSAXExceptionExtendedContentHandler.addUniqueAttribute(java.lang.String, java.lang.String, int)public void characters(Node node) throws SAXException
node - a DOM Node containing text.SAXExceptionExtendedContentHandler.characters(org.w3c.dom.Node)public void addXSLAttribute(String qName, String value, String uri)
qName - the qualified attribute name (prefix:localName)value - the attributes valueuri - the uri that the prefix of the qName is mapped to.ExtendedContentHandler.addXSLAttribute(java.lang.String, java.lang.String, java.lang.String)public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException
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 attributeSAXExceptionExtendedContentHandler.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)
SerializationHandlersetDTDEntityExpansion in interface SerializationHandlerexpand - true if DTD entities are to be expanded,
false if they are to be left as DTD entity references.SerializationHandler.setDTDEntityExpansion(boolean)Copyright © 2018–2021 mhoffrogge. All rights reserved.