|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.novell.xml.dom.DOMWriter
This class is a serializer for the DOM. It takes a DOM level-1.0 node and outputs it as XML. If the java.io.Writer object passed to the constructor is of type java.io.OutputStreamWriter or com.novell.io.EncodingStreamWriter then encoding into different character sets can be performed. This class also provides methods to set serialization options corresponding to the XSLT xsl:output element attributes.
Field Summary | |
protected int |
baseIndentLevel
|
protected boolean |
cdataOutput
|
protected Collection |
cdataSectionElements
|
protected boolean |
disableTextEscaping
|
protected String |
doctypePublic
|
protected String |
doctypeSystem
|
protected String |
encoding
|
protected Node |
firstDocChild
|
protected boolean |
indent
|
protected int |
indentLevel
|
protected String |
indentString
|
protected Node |
root
|
protected Stack |
stack
|
protected boolean |
standalone
|
protected boolean |
writeDeclaration
|
protected Writer |
writer
|
protected static int |
XML_SPACE_DEFAULT
|
protected static int |
XML_SPACE_PRESERVE
|
protected int |
xmlSpace
|
protected static Integer |
xmlSpaceDefault
|
protected static Integer |
xmlSpacePreserve
|
Constructor Summary | |
DOMWriter(Node node,
OutputStream outputStream,
String encoding)
Construct a DOMWriter for the passed OutputStream, using the passed encoding, if possible. |
|
DOMWriter(Node node,
Writer writer)
Construct a DOMWriter object for a given java.io.Writer object. |
Method Summary | |
void |
flush()
Flush the underlying writer attached to this DOMWriter |
Collection |
getCdataSectionElements()
Get the list of element tag names whose text content should be output as CDATA sections. |
boolean |
getDisableTextEscaping()
Return non-zero if XML text escaping is disabled for this XmlWriter. |
String |
getDoctypePublic()
Return the DOCTYPE PUBLIC id to use for the DTD declaration |
String |
getDoctypeSystem()
Return the DOCTYPE SYSTEM id to use for the XML-declaration |
String |
getEncoding()
Get the encoding string that will be specified in the XML declaration, if a declaration is output |
boolean |
getIndent()
Return if this object will inject whitespace to "pretty print" the serialization of a DOM tree |
boolean |
getStandalone()
Return if this object will write a "standalone=yes" declaration in the XML-declaration. |
boolean |
getWriteDeclaration()
Return if this object will write an XML-declaration when it serializes a DOM tree |
protected void |
injectWhitespace(Node node)
Conditionally inject whitespace between elements, comments, and processing instructions to "pretty-print" the serialization. |
protected void |
popState()
|
protected void |
pushState()
|
void |
setBaseIndentLevel(int level)
Set the the starting indentation level during "pretty print" serialization. |
void |
setCdataSectionElements(Collection cdataSectionElements)
Set the list of element tag names whose text content should be output as CDATA sections. |
void |
setDisableTextEscaping(boolean disableTextEscaping)
Set if XML text escaping is to be disabled for this XmlWriter. |
void |
setDoctypePublic(String doctypePublic)
Set the DOCTYPE PUBLIC id to use in the DTD declaration Note that this will only be used if the DOCTYPE SYSTEM id is not null and non-empty (see setDoctypeSystem()), and that the public id overrides the system id. |
void |
setDoctypeSystem(String doctypeSystem)
Set the DOCTYPE SYSTEM id to use in the DTD declaration Note that this will be overridden by the DOCTYPE PUBLIC id (see setDoctypePublic()), but must be set to use the public id. |
void |
setEncoding(String encoding)
Set the encoding string that will be specified in the XML declaration, if a declaration is output. |
void |
setIndent(boolean indent)
Set whether this object should inject whitespace to "pretty print" the serialization of a DOM tree. |
void |
setIndentString(String indentString)
Set the string used to indent during "pretty print" serialization of a DOM tree. |
void |
setStandalone(boolean standalone)
Set whether this object should write a "standalone=yes" declaration in the XML-declaration |
void |
setWriteDeclaration(boolean writeDeclaration)
Set whether this object should output an XML-declaration when it serializes a DOM tree |
protected boolean |
useCdataOutput(Element element)
Return whether or not CDATA section output should be used for text children of the passed element's name |
void |
write()
Serialize a DOM subtree as XML |
protected void |
writeDeclaration()
Write an XML declaration, optionally writing an encoding declaration and a standalone declaration. |
protected void |
writeDTD(Document node)
Write a DTD declaration. |
protected void |
writeTree(Node node)
Serialize the subtree with the passed node as root. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Node root
protected Node firstDocChild
protected Writer writer
protected String encoding
protected boolean indent
protected boolean writeDeclaration
protected boolean standalone
protected String doctypePublic
protected String doctypeSystem
protected int indentLevel
protected boolean disableTextEscaping
protected Collection cdataSectionElements
protected boolean cdataOutput
protected Stack stack
protected static final int XML_SPACE_DEFAULT
protected static final int XML_SPACE_PRESERVE
protected static final Integer xmlSpaceDefault
protected static final Integer xmlSpacePreserve
protected int xmlSpace
protected String indentString
protected int baseIndentLevel
Constructor Detail |
public DOMWriter(Node node, Writer writer)
node
- The root of the DOM tree to outputwriter
- The writer object to use.public DOMWriter(Node node, OutputStream outputStream, String encoding) throws UnsupportedEncodingException
node
- The root of the DOM tree to outputoutputStream
- The OutputStream to which to writeencoding
- The name of the character encoding to useMethod Detail |
public void write() throws IOException
write
in interface XmlWriter
IOException
public void flush() throws IOException
IOException
public boolean getWriteDeclaration()
getWriteDeclaration
in interface XmlWriter
public void setWriteDeclaration(boolean writeDeclaration)
setWriteDeclaration
in interface XmlWriter
writeDeclaration
- True if an XML-declaration should be writtenpublic String getEncoding()
getEncoding
in interface XmlWriter
public void setEncoding(String encoding)
setEncoding
in interface XmlWriter
encoding
- The encoding string to place in the xml
declarationpublic boolean getIndent()
getIndent
in interface XmlWriter
public void setIndent(boolean indent)
setIndent
in interface XmlWriter
indent
- True if whitespace should be injected to "pretty print"
the XML serialization of a DOM tree.public void setIndentString(String indentString)
indentString
- string to use for pretty printpublic void setBaseIndentLevel(int level)
level
- level to initialize indentation to at start of serializationpublic boolean getStandalone()
getStandalone
in interface XmlWriter
public void setStandalone(boolean standalone)
setStandalone
in interface XmlWriter
standalone
- True if a standalone="yes" declaration should be
written in the XML-declarationpublic String getDoctypePublic()
getDoctypePublic
in interface XmlWriter
public void setDoctypePublic(String doctypePublic)
setDoctypePublic
in interface XmlWriter
doctypePublic
- The DOCTYPE PUBLIC id to use in the DTD declaration
or null if none should be used.public String getDoctypeSystem()
getDoctypeSystem
in interface XmlWriter
public void setDoctypeSystem(String doctypeSystem)
setDoctypeSystem
in interface XmlWriter
doctypeSystem
- The DOCTYPE SYSTEM id to use in the DTD declaration
or null if none should be used.public boolean getDisableTextEscaping()
getDisableTextEscaping
in interface XmlWriter
public void setDisableTextEscaping(boolean disableTextEscaping)
setDisableTextEscaping
in interface XmlWriter
disableTextEscaping
- True if text escaping is disabledpublic Collection getCdataSectionElements()
getCdataSectionElements
in interface XmlWriter
public void setCdataSectionElements(Collection cdataSectionElements)
setCdataSectionElements
in interface XmlWriter
cdataSectionElements
- A Collection of ExpandedQName objects, each
of which represents an element tag name.protected void writeDeclaration() throws IOException
IOException
protected void writeDTD(Document node) throws IOException
node
- The Document node for the DOM tree.
IOException
protected void writeTree(Node node) throws IOException
node
- The root of the subtree to output.
IOException
protected void injectWhitespace(Node node) throws IOException
node
- The node before which to inject whitespace
IOException
protected boolean useCdataOutput(Element element)
element
- The element to checkprotected void pushState()
protected void popState()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |