A rule implementation that creates a DOM {@link org.w3c.dom.Node Node} containing the XML at the element that matchedthe rule. Two concrete types of nodes can be created by this rule:
- the default is to create an {@link org.w3c.dom.Element Element} node. The created element will correspond to theelement that matched the rule, containing all XML content underneath that element.
- alternatively, this rule can create nodes of type {@link org.w3c.dom.DocumentFragment DocumentFragment}, which will contain only the XML content under the element the rule was trigged on.
The created node will be normalized, meaning it will not contain text nodes that only contain white space characters.
The created Node
will be pushed on Digester's object stack when done. To use it in the context of another DOM {@link org.w3c.dom.Document Document}, it must be imported first, using the Document method {@link org.w3c.dom.Document#importNode(org.w3c.dom.Node,boolean) importNode()}.
Important Note: This is implemented by replacing the SAX {@link org.xml.sax.ContentHandler ContentHandler} in the parser used by Digester, and resetting it when the matched element is closed. As a sideeffect, 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.
@since Digester 1.4