public class NodeCreateRule extends Rule
Node
containing the XML at the element that matched
the rule. Two concrete types of nodes can be created by this rule:
Element
node.
The created element will correspond to the element that matched the rule,
containing all XML content underneath that element.DocumentFragment
, which will contain
only the XML content under the element the rule was triggered on.The created Node
will be pushed on Digester's object stack
when done. To use it in the context of another DOM
Document
, it must be imported first, using the
Document method
importNode()
.
Important Note: This is implemented by replacing the SAX
ContentHandler
in the parser used by
Digester, and resetting it when the matched element is closed. As a side
effect, rules that would match XML nodes under the element that matches
a NodeCreateRule
will never be triggered by Digester, which
usually is the behavior one would expect.
Note that the current implementation does not set the namespace prefixes in the exported nodes. The (usually more important) namespace URIs are set, of course.
digester, namespaceURI
Constructor and Description |
---|
NodeCreateRule()
Default constructor.
|
NodeCreateRule(javax.xml.parsers.DocumentBuilder documentBuilder)
Constructor.
|
NodeCreateRule(int nodeType)
Constructor.
|
NodeCreateRule(int nodeType,
javax.xml.parsers.DocumentBuilder documentBuilder)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
begin(java.lang.String namespaceURI,
java.lang.String name,
org.xml.sax.Attributes attributes)
Implemented to replace the content handler currently in use by a
NodeBuilder.
|
void |
end(java.lang.String namespace,
java.lang.String name)
Pop the Node off the top of the stack.
|
begin, body, body, end, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI
public NodeCreateRule() throws javax.xml.parsers.ParserConfigurationException
Element
.javax.xml.parsers.ParserConfigurationException
public NodeCreateRule(javax.xml.parsers.DocumentBuilder documentBuilder)
Element
, but lets you specify the JAXP
DocumentBuilder
that should be used when constructing the
node tree.documentBuilder
- the JAXP DocumentBuilder
to usepublic NodeCreateRule(int nodeType) throws javax.xml.parsers.ParserConfigurationException
Element
or a DOM
DocumentFragment
, depending on the
value of the nodeType
parameter.nodeType
- the type of node to create, which can be either
Node.ELEMENT_NODE
or
Node.DOCUMENT_FRAGMENT_NODE
java.lang.IllegalArgumentException
- if the node type is not supportedjavax.xml.parsers.ParserConfigurationException
public NodeCreateRule(int nodeType, javax.xml.parsers.DocumentBuilder documentBuilder)
Element
or a DOM
DocumentFragment
, depending on the
value of the nodeType
parameter. This constructor lets you
specify the JAXP DocumentBuilder
that should be used when
constructing the node tree.nodeType
- the type of node to create, which can be either
Node.ELEMENT_NODE
or
Node.DOCUMENT_FRAGMENT_NODE
documentBuilder
- the JAXP DocumentBuilder
to usejava.lang.IllegalArgumentException
- if the node type is not supportedpublic void begin(java.lang.String namespaceURI, java.lang.String name, org.xml.sax.Attributes attributes) throws java.lang.Exception
begin
in class Rule
namespaceURI
- the namespace URI of the matching element, or an
empty string if the parser is not namespace aware or the element has
no namespacename
- the local name if the parser is namespace aware, or just
the element name otherwiseattributes
- The attribute list of this elementjava.lang.Exception
- indicates a JAXP configuration problempublic void end(java.lang.String namespace, java.lang.String name) throws java.lang.Exception
end
in class Rule
namespace
- the namespace URI of the matching element, or an
empty string if the parser is not namespace aware or the element has
no namespacename
- the local name if the parser is namespace aware, or just
the element name otherwisejava.lang.Exception
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.