|
|||||||||
| Home >> All >> gnu >> xml >> dom >> [ ls overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
gnu.xml.dom.ls
Class DomLSSerializer

java.lang.Objectgnu.xml.transform.StreamSerializer
gnu.xml.dom.ls.DomLSSerializer
- All Implemented Interfaces:
- org.w3c.dom.DOMConfiguration, org.w3c.dom.DOMStringList, org.w3c.dom.ls.LSSerializer
- public class DomLSSerializer
- extends gnu.xml.transform.StreamSerializer
- implements org.w3c.dom.ls.LSSerializer, org.w3c.dom.DOMConfiguration, org.w3c.dom.DOMStringList
- extends gnu.xml.transform.StreamSerializer
Serialize a DOM node to a stream.
| Field Summary | |
private org.w3c.dom.ls.LSSerializerFilter |
filter
|
private gnu.xml.transform.StreamSerializer |
serializer
|
private static java.util.List |
SUPPORTED_PARAMETERS
|
| Fields inherited from class gnu.xml.transform.StreamSerializer |
discardDefaultContent, encoding, eol, xmlDeclaration |
| Constructor Summary | |
DomLSSerializer()
|
|
| Method Summary | |
boolean |
canSetParameter(java.lang.String name,
java.lang.Object value)
Check if setting a parameter to a specific value is supported. |
boolean |
contains(java.lang.String str)
Test if a string is part of this DOMStringList. |
org.w3c.dom.DOMConfiguration |
getDomConfig()
The DOMConfiguration object used by the
LSSerializer when serializing a DOM node. |
org.w3c.dom.ls.LSSerializerFilter |
getFilter()
When the application provides a filter, the serializer will call out to the filter before serializing each Node. |
int |
getLength()
The number of DOMStrings in the list. |
java.lang.String |
getNewLine()
The end-of-line sequence of characters to be used in the XML being written out. |
java.lang.Object |
getParameter(java.lang.String name)
Return the value of a parameter if known. |
org.w3c.dom.DOMStringList |
getParameterNames()
The list of the parameters supported by this DOMConfiguration object and for which at least one value
can be set by the application. |
java.lang.String |
item(int i)
Returns the indexth item in the collection. |
void |
serialize(org.w3c.dom.Node node,
java.io.OutputStream out)
|
void |
setFilter(org.w3c.dom.ls.LSSerializerFilter filter)
When the application provides a filter, the serializer will call out to the filter before serializing each Node. |
void |
setNewLine(java.lang.String newLine)
The end-of-line sequence of characters to be used in the XML being written out. |
void |
setParameter(java.lang.String name,
java.lang.Object value)
Set the value of a parameter. |
boolean |
write(org.w3c.dom.Node node,
org.w3c.dom.ls.LSOutput output)
Serialize the specified node as described above in the general description of the LSSerializer interface. |
java.lang.String |
writeToString(org.w3c.dom.Node node)
Serialize the specified node as described above in the general description of the LSSerializer interface. |
boolean |
writeToURI(org.w3c.dom.Node node,
java.lang.String uri)
A convenience method that acts as if LSSerializer.write
was called with a LSOutput with no encoding specified
and LSOutput.systemId set to the uri
argument. |
| Methods inherited from class gnu.xml.transform.StreamSerializer |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
SUPPORTED_PARAMETERS
private static final java.util.List SUPPORTED_PARAMETERS
filter
private org.w3c.dom.ls.LSSerializerFilter filter
serializer
private gnu.xml.transform.StreamSerializer serializer
| Constructor Detail |
DomLSSerializer
public DomLSSerializer()
| Method Detail |
getDomConfig
public org.w3c.dom.DOMConfiguration getDomConfig()
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - The
DOMConfigurationobject used by theLSSerializerwhen serializing a DOM node.
In addition to the parameters recognized by the DOMConfiguration interface defined in [DOM Level 3 Core] , theDOMConfigurationobjects forLSSerializeradds, or modifies, the following parameters:"canonical-form"-
true- [optional] Writes the document according to the rules specified in [Canonical XML].
In addition to the behavior described in "
canonical-form" [DOM Level 3 Core]
, setting this parameter to
truewill set the parameters "format-pretty-print", "discard-default-content", and "xml-declaration ", tofalse. Setting one of those parameters totruewill set this parameter tofalse. Serializing an XML 1.1 document when "canonical-form" istruewill generate a fatal error. false- [required] (default) Do not canonicalize the output.
"discard-default-content"-
-
true - [required] (default) Use the
Attr.specifiedattribute to decide what attributes should be discarded. Note that some implementations might use whatever information available to the implementation (i.e. XML schema, DTD, theAttr.specifiedattribute, and so on) to determine what attributes and content to discard if this parameter is set totrue. false- [required]Keep all attributes and all content.
-
"format-pretty-print"-
-
true - [optional] Formatting the output by adding whitespace to produce a pretty-printed, indented, human-readable form. The exact form of the transformations is not specified by this specification. Pretty-printing changes the content of the document and may affect the validity of the document, validating implementations should preserve validity.
-
false - [required] (default) Don't pretty-print the result.
-
-
"ignore-unknown-character-denormalizations" -
-
true - [required] (default) If, while verifying full normalization when [XML 1.1] is
supported, a character is encountered for which the normalization
properties cannot be determined, then raise a
"unknown-character-denormalization"warning (instead of raising an error, if this parameter is not set) and ignore any possible denormalizations caused by these characters. -
false - [optional] Report a fatal error if a character is encountered for which the processor cannot determine the normalization properties.
-
-
"normalize-characters" - This parameter is equivalent to
the one defined by
DOMConfigurationin [DOM Level 3 Core] . Unlike in the Core, the default value for this parameter istrue. While DOM implementations are not required to support fully normalizing the characters in the document according to appendix E of [XML 1.1], this parameter must be activated by default if supported. -
"xml-declaration" -
true- [required] (default) If a
Document,Element, orEntitynode is serialized, the XML declaration, or text declaration, should be included. The version (Document.xmlVersionif the document is a Level 3 document and the version is non-null, otherwise use the value "1.0"), and the output encoding (seeLSSerializer.writefor details on how to find the output encoding) are specified in the serialized XML declaration. -
false - [required] Do not serialize the XML and text declarations. Report a
"xml-declaration-needed"warning if this will cause problems (i.e. the serialized data is of an XML version other than [XML 1.0], or an encoding would be needed to be able to re-parse the serialized data).
- Specified by:
getDomConfigin interfaceorg.w3c.dom.ls.LSSerializer
getNewLine
public java.lang.String getNewLine()
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - The end-of-line sequence of characters to be used in the XML being
written out. Any string is supported, but XML treats only a certain
set of characters sequence as end-of-line (See section 2.11,
"End-of-Line Handling" in [XML 1.0], if the
serialized content is XML 1.0 or section 2.11, "End-of-Line Handling"
in [XML 1.1], if the
serialized content is XML 1.1). Using other character sequences than
the recommended ones can result in a document that is either not
serializable or not well-formed).
On retrieval, the default value of this attribute is the implementation specific default end-of-line sequence. DOM implementations should choose the default to match the usual convention for text files in the environment being used. Implementations must choose a default sequence that matches one of those allowed by XML 1.0 or XML 1.1, depending on the serialized content. Setting this attribute tonullwill reset its value to the default value.
- Specified by:
getNewLinein interfaceorg.w3c.dom.ls.LSSerializer
setNewLine
public void setNewLine(java.lang.String newLine)
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - The end-of-line sequence of characters to be used in the XML being
written out. Any string is supported, but XML treats only a certain
set of characters sequence as end-of-line (See section 2.11,
"End-of-Line Handling" in [XML 1.0], if the
serialized content is XML 1.0 or section 2.11, "End-of-Line Handling"
in [XML 1.1], if the
serialized content is XML 1.1). Using other character sequences than
the recommended ones can result in a document that is either not
serializable or not well-formed).
On retrieval, the default value of this attribute is the implementation specific default end-of-line sequence. DOM implementations should choose the default to match the usual convention for text files in the environment being used. Implementations must choose a default sequence that matches one of those allowed by XML 1.0 or XML 1.1, depending on the serialized content. Setting this attribute tonullwill reset its value to the default value.
- Specified by:
setNewLinein interfaceorg.w3c.dom.ls.LSSerializer
getFilter
public org.w3c.dom.ls.LSSerializerFilter getFilter()
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - When the application provides a filter, the serializer will call out
to the filter before serializing each Node. The filter implementation
can choose to remove the node from the stream or to terminate the
serialization early.
The filter is invoked after the operations requested by theDOMConfigurationparameters have been applied. For example, CDATA sections won't be passed to the filter if " cdata-sections" is set tofalse.- Specified by:
getFilterin interfaceorg.w3c.dom.ls.LSSerializer
setFilter
public void setFilter(org.w3c.dom.ls.LSSerializerFilter filter)
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - When the application provides a filter, the serializer will call out
to the filter before serializing each Node. The filter implementation
can choose to remove the node from the stream or to terminate the
serialization early.
The filter is invoked after the operations requested by theDOMConfigurationparameters have been applied. For example, CDATA sections won't be passed to the filter if " cdata-sections" is set tofalse.- Specified by:
setFilterin interfaceorg.w3c.dom.ls.LSSerializer
write
public boolean write(org.w3c.dom.Node node, org.w3c.dom.ls.LSOutput output) throws org.w3c.dom.ls.LSException
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - Serialize the specified node as described above in the general
description of the
LSSerializerinterface. The output is written to the suppliedLSOutput.
When writing to aLSOutput, the encoding is found by looking at the encoding information that is reachable through theLSOutputand the item to be written (or its owner document) in this order:-
LSOutput.encoding, -
Document.inputEncoding, -
Document.xmlEncoding.
If no encoding is reachable through the above properties, a default encoding of "UTF-8" will be used. If the specified encoding is not supported an "unsupported-encoding" fatal error is raised.
If no output is specified in theLSOutput, a "no-output-specified" fatal error is raised.
The implementation is responsible of associating the appropriate media type with the serialized data.
When writing to a HTTP URI, a HTTP PUT is performed. When writing to other types of URIs, the mechanism for writing the data to the URI is implementation dependent.- Specified by:
writein interfaceorg.w3c.dom.ls.LSSerializer
-
writeToURI
public boolean writeToURI(org.w3c.dom.Node node, java.lang.String uri) throws org.w3c.dom.ls.LSException
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - A convenience method that acts as if
LSSerializer.writewas called with aLSOutputwith no encoding specified andLSOutput.systemIdset to theuriargument.- Specified by:
writeToURIin interfaceorg.w3c.dom.ls.LSSerializer
writeToString
public java.lang.String writeToString(org.w3c.dom.Node node) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSException
- Description copied from interface:
org.w3c.dom.ls.LSSerializer - Serialize the specified node as described above in the general
description of the
LSSerializerinterface. The output is written to aDOMStringthat is returned to the caller. The encoding used is the encoding of theDOMStringtype, i.e. UTF-16. Note that no Byte Order Mark is generated in aDOMStringobject.- Specified by:
writeToStringin interfaceorg.w3c.dom.ls.LSSerializer
serialize
public void serialize(org.w3c.dom.Node node, java.io.OutputStream out) throws java.io.IOException
setParameter
public void setParameter(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.DOMConfiguration - Set the value of a parameter.
- Specified by:
setParameterin interfaceorg.w3c.dom.DOMConfiguration
getParameter
public java.lang.Object getParameter(java.lang.String name) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.DOMConfiguration - Return the value of a parameter if known.
- Specified by:
getParameterin interfaceorg.w3c.dom.DOMConfiguration
canSetParameter
public boolean canSetParameter(java.lang.String name, java.lang.Object value)
- Description copied from interface:
org.w3c.dom.DOMConfiguration - Check if setting a parameter to a specific value is supported.
- Specified by:
canSetParameterin interfaceorg.w3c.dom.DOMConfiguration
getParameterNames
public org.w3c.dom.DOMStringList getParameterNames()
- Description copied from interface:
org.w3c.dom.DOMConfiguration - The list of the parameters supported by this
DOMConfigurationobject and for which at least one value can be set by the application. Note that this list can also contain parameter names defined outside this specification.- Specified by:
getParameterNamesin interfaceorg.w3c.dom.DOMConfiguration
item
public java.lang.String item(int i)
- Description copied from interface:
org.w3c.dom.DOMStringList - Returns the
indexth item in the collection. Ifindexis greater than or equal to the number ofDOMStrings in the list, this returnsnull.- Specified by:
itemin interfaceorg.w3c.dom.DOMStringList
getLength
public int getLength()
- Description copied from interface:
org.w3c.dom.DOMStringList - The number of
DOMStrings in the list. The range of valid child node indices is 0 tolength-1inclusive.- Specified by:
getLengthin interfaceorg.w3c.dom.DOMStringList
contains
public boolean contains(java.lang.String str)
- Description copied from interface:
org.w3c.dom.DOMStringList - Test if a string is part of this
DOMStringList.- Specified by:
containsin interfaceorg.w3c.dom.DOMStringList
|
|||||||||
| Home >> All >> gnu >> xml >> dom >> [ ls overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC