public final class DOMSource extends java.lang.Object implements Source
A Source whose content comes from a DOM node. The referenced node may be a full-fledged org.w3c.dom.Document
, but it may also be an internal node in a larger document.
The serialization representation is XML text with a particular chracter set encoding. The encoding used can be specified via TransformOptions
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DOM_IMPL_LS
an optional transform option that tells the source/transformer to use the specified instance of org.w3c.dom.ls.DOMImplementationLS to for creation of DOM nodes e.g.
|
DEFAULT_CHARACTER_SET_ENCODING
Constructor and Description |
---|
DOMSource(org.w3c.dom.Node node)
Create a new Source from a DOM node.
|
DOMSource(org.w3c.dom.Node node, java.lang.String systemID)
Create a new input source with a DOM node, and with the system ID also passed in as the base URI.
|
Modifier and Type | Method and Description |
---|---|
java.io.InputStream |
getInputStream(TransformOptions options)
Returns streaming byte-baseed representation of the Source's content.
|
org.w3c.dom.Node |
getNode()
Get the underlying DOM node for this Source
|
java.lang.String |
getSystemId()
Get the base ID (URL or system ID)
|
void |
writeTo(java.io.OutputStream os, TransformOptions options)
Serializes the Source's content to a byte-based stream.
|
public static final java.lang.String DOM_IMPL_LS
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS lsImpl = (DOMImplementationLS)registry.getDOMImplementation("LS"); (or something like lsImpl = oracle.xml.parser.v2.XMLDOMImplementation() ) options.put(DOMSource.DOM_IMPL_LS, lsImpl); DOMSource dom = ...getTransformer().transform(source, DOMSource.class, options);If not specified, the default platform DOM implementation LS will be used.
public DOMSource(org.w3c.dom.Node node)
node
- The DOM node that will be this Source's contentpublic DOMSource(org.w3c.dom.Node node, java.lang.String systemID)
node
- The DOM node that will be this Source's contentsystemID
- Specifies the base URI associated with node.public org.w3c.dom.Node getNode()
public java.lang.String getSystemId()
public java.io.InputStream getInputStream(TransformOptions options) throws java.io.IOException, TransformException
Source
getInputStream
in interface Source
options
- Options used to affect the serializationjava.io.IOException
TransformException
public void writeTo(java.io.OutputStream os, TransformOptions options) throws java.io.IOException, TransformException
Source
Note that this method may involve an internal transformation, although it should not in any way change the underlying content.
writeTo
in interface Source
os
- the OutputStream to which serialized content will be writtenoptions
- TransformOptions used to affect the serializationjava.io.IOException
TransformException