| java.lang.Object org.apache.tomcat.util.digester.Rule org.apache.tomcat.util.digester.NodeCreateRule
NodeCreateRule | public class NodeCreateRule extends Rule (Code) | | A rule implementation that creates a DOM
org.w3c.dom.Node Node containing the XML at the element that matched
the rule. Two concrete types of nodes can be created by this rule:
- the default is to create an
org.w3c.dom.Element Element node.
The created element will correspond to the element that matched the rule,
containing all XML content underneath that element.
- alternatively, this rule can create nodes of type
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
org.w3c.dom.Document Document , it must be imported first, using the
Document method
org.w3c.dom.Document.importNode(org.w3c.dom.Nodeboolean) importNode() .
Important Note: This is implemented by replacing the SAX
org.xml.sax.ContentHandler 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.
since: Digester 1.4 |
Method Summary | |
public void | begin(String namespaceURI, String name, Attributes attributes) Implemented to replace the content handler currently in use by a
NodeBuilder. | public void | end() Pop the Node off the top of the stack. |
NodeCreateRule | public NodeCreateRule(DocumentBuilder documentBuilder)(Code) | | Constructor. Creates an instance of this rule that will create a DOM
org.w3c.dom.Element Element , but lets you specify the JAXP
DocumentBuilder that should be used when constructing the
node tree.
Parameters: documentBuilder - the JAXP DocumentBuilder to use |
begin | public void begin(String namespaceURI, String name, Attributes attributes) throws Exception(Code) | | Implemented to replace the content handler currently in use by a
NodeBuilder.
Parameters: namespaceURI - the namespace URI of the matching element, or an empty string if the parser is not namespace aware or the element hasno namespace Parameters: name - the local name if the parser is namespace aware, or just the element name otherwise Parameters: attributes - The attribute list of this element throws: Exception - indicates a JAXP configuration problem |
end | public void end() throws Exception(Code) | | Pop the Node off the top of the stack.
|
|
|