public class W3CDomHandler extends java.lang.Object implements DomHandler<org.w3c.dom.Element,javax.xml.transform.dom.DOMResult>
DomHandler
implementation for W3C DOM (org.w3c.dom
package.)Constructor and Description |
---|
W3CDomHandler()
Default constructor.
|
W3CDomHandler(javax.xml.parsers.DocumentBuilder builder)
Constructor that allows applications to specify which DOM implementation
to be used.
|
Modifier and Type | Method and Description |
---|---|
javax.xml.transform.dom.DOMResult |
createUnmarshaller(ValidationEventHandler errorHandler)
When a Jakarta XML Binding provider needs to unmarshal a part of a document into an
infoset representation, it first calls this method to create a
Result object. |
javax.xml.parsers.DocumentBuilder |
getBuilder() |
org.w3c.dom.Element |
getElement(javax.xml.transform.dom.DOMResult r)
Once the portion is sent to the
Result . |
javax.xml.transform.Source |
marshal(org.w3c.dom.Element element,
ValidationEventHandler errorHandler)
This method is called when a Jakarta XML Binding provider needs to marshal an element
to XML.
|
void |
setBuilder(javax.xml.parsers.DocumentBuilder builder) |
public W3CDomHandler()
public W3CDomHandler(javax.xml.parsers.DocumentBuilder builder)
builder
- must not be null. Jakarta XML Binding uses this DocumentBuilder
to create
a new element.public javax.xml.parsers.DocumentBuilder getBuilder()
public void setBuilder(javax.xml.parsers.DocumentBuilder builder)
public javax.xml.transform.dom.DOMResult createUnmarshaller(ValidationEventHandler errorHandler)
DomHandler
Result
object.
A Jakarta XML Binding provider will then send a portion of the XML into the given result. Such a portion always form a subtree of the whole XML document rooted at an element.
createUnmarshaller
in interface DomHandler<org.w3c.dom.Element,javax.xml.transform.dom.DOMResult>
errorHandler
- if any error happens between the invocation of this method
and the invocation of DomHandler.getElement(Result)
, they
must be reported to this handler.
The caller must provide a non-null error handler.
The Result
object created from this method
may hold a reference to this error handler.public org.w3c.dom.Element getElement(javax.xml.transform.dom.DOMResult r)
DomHandler
Result
. This method is called
by a Jakarta XML Binding provider to obtain the unmarshalled element representation.
Multiple invocations of this method may return different objects.
This method can be invoked only when the whole sub-tree are fed
to the Result
object.
getElement
in interface DomHandler<org.w3c.dom.Element,javax.xml.transform.dom.DOMResult>
r
- The Result
object created by DomHandler.createUnmarshaller(ValidationEventHandler)
.public javax.xml.transform.Source marshal(org.w3c.dom.Element element, ValidationEventHandler errorHandler)
DomHandler
If non-null, the returned Source
must contain a whole document
rooted at one element, which will then be weaved into a bigger document
that the Jakarta XML Binding provider is marshalling.
marshal
in interface DomHandler<org.w3c.dom.Element,javax.xml.transform.dom.DOMResult>
errorHandler
- Receives any errors happened during the process of converting
an element into a Source
.
The caller must provide a non-null error handler.