public class DOMConverter extends Object
Modifier and Type | Field and Description |
---|---|
protected DocumentBuilder |
_docBuilder |
protected boolean |
_inputCfgIgnoreWs
Whether ignorable white space should be ignored, ie not added
in the resulting JDOM tree.
|
Constructor and Description |
---|
DOMConverter() |
DOMConverter(DocumentBuilder b) |
Modifier and Type | Method and Description |
---|---|
protected String |
_buildDTD(DocumentType doctype) |
protected static boolean |
_isNamespaceAware(XMLStreamReader r) |
protected void |
_writeElement(org.codehaus.stax2.XMLStreamWriter2 sw,
Element elem)
Method called to output an element node and all of its children
(recursively).
|
protected void |
_writeNode(org.codehaus.stax2.XMLStreamWriter2 sw,
Node node) |
Document |
buildDocument(XMLStreamReader r)
This method will create a
Document instance using
the default JAXP DOM document construction mechanism and
populated using the given StAX stream reader. |
void |
buildDocument(XMLStreamReader r,
Document doc)
This method will populate given
Document using
the given StAX stream reader instance. |
Document |
buildDocument(XMLStreamReader r,
DocumentBuilder docbuilder)
This method will create a
Document instance using
given DocumentBuilder and
populated using the given StAX stream reader. |
void |
setIgnoreWhitespace(boolean state)
Method used to change whether the build methods will add ignorable
(element) white space in the DOM tree or not.
|
void |
writeDocument(Document doc,
XMLStreamWriter sw0)
Method for writing out given DOM document using specified
stream writer.
|
void |
writeFragment(NodeList nodes,
XMLStreamWriter sw0) |
void |
writeFragment(Node node,
XMLStreamWriter sw0) |
protected final DocumentBuilder _docBuilder
protected boolean _inputCfgIgnoreWs
public DOMConverter()
public DOMConverter(DocumentBuilder b)
public void setIgnoreWhitespace(boolean state)
Whether all-whitespace text segment is ignorable white space or not is based on DTD read in, as per XML specifications (white space is only significant in mixed content or pure text elements).
public Document buildDocument(XMLStreamReader r) throws XMLStreamException
Document
instance using
the default JAXP DOM document construction mechanism and
populated using the given StAX stream reader.
Namespace-awareness will be enabled for the
DocumentBuilderFactory
constructed; if this is not wanted,
caller should construct DocumentBuilder separately.
Note: underlying stream reader will not be closed by calling this method.
r
- Stream reader from which input is read.Document
- DOM document object.XMLStreamException
- If the reader threw such exception (to
indicate a parsing or I/O problem)public Document buildDocument(XMLStreamReader r, DocumentBuilder docbuilder) throws XMLStreamException
Document
instance using
given DocumentBuilder and
populated using the given StAX stream reader.
Note: underlying stream reader will not be closed by calling this method.
r
- Stream reader from which input is read.Document
- DOM document object.XMLStreamException
- If the reader threw such exception (to
indicate a parsing or I/O problem)public void buildDocument(XMLStreamReader r, Document doc) throws XMLStreamException
Document
using
the given StAX stream reader instance.
This method takes a XMLStreamReader
and builds up
a DOM tree under given document object.
Implementation note: recursion has been eliminated by using nodes' parent/child relationship; this improves performance somewhat (classic recursion-by-iteration-and-explicit stack transformation)
Note: underlying stream reader will not be closed by calling this method.
r
- Stream reader from which input is read.doc
- Document
being built.XMLStreamException
- If the reader threw such exception (to
indicate a parsing or I/O problem)public void writeDocument(Document doc, XMLStreamWriter sw0) throws XMLStreamException
Note: only regular XMLStreamWriter.close()
is
called on the stream writer. This usually means that the underlying
stream is not closed (as per Stax 1.0 specification).
XMLStreamException
public void writeFragment(NodeList nodes, XMLStreamWriter sw0) throws XMLStreamException
XMLStreamException
public void writeFragment(Node node, XMLStreamWriter sw0) throws XMLStreamException
XMLStreamException
protected static boolean _isNamespaceAware(XMLStreamReader r) throws XMLStreamException
XMLStreamException
protected void _writeNode(org.codehaus.stax2.XMLStreamWriter2 sw, Node node) throws XMLStreamException
XMLStreamException
protected String _buildDTD(DocumentType doctype)
protected void _writeElement(org.codehaus.stax2.XMLStreamWriter2 sw, Element elem) throws XMLStreamException
elem
- Element to outputXMLStreamException
Copyright © 2013 FasterXML. All Rights Reserved.