|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.digester3.Rule
org.apache.commons.digester3.NodeCreateRule
public class NodeCreateRule
A rule implementation that creates a DOM 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 trigged 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.
| Constructor Summary | |
|---|---|
NodeCreateRule()
Default constructor. |
|
NodeCreateRule(DocumentBuilder documentBuilder)
Constructor. |
|
NodeCreateRule(int nodeType)
Constructor. |
|
NodeCreateRule(int nodeType,
DocumentBuilder documentBuilder)
Constructor. |
|
| Method Summary | |
|---|---|
void |
begin(String namespaceURI,
String name,
Attributes attributes)
When this method fires, the digester is told to forward all SAX ContentHandler events to the builder object, resulting in a DOM being built instead of normal digester rule-handling occurring. |
void |
end(String namespace,
String name)
This method is called when the end of a matching XML element is encountered. |
| Methods inherited from class org.apache.commons.digester3.Rule |
|---|
body, finish, getDigester, getNamespaceURI, setDigester, setNamespaceURI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NodeCreateRule()
throws ParserConfigurationException
Element.
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the
configuration requested.DocumentBuilderFactory.newDocumentBuilder()public NodeCreateRule(DocumentBuilder documentBuilder)
Element, but
lets you specify the JAXP DocumentBuilder that should be used when constructing the node tree.
documentBuilder - the JAXP DocumentBuilder to use
public NodeCreateRule(int nodeType)
throws 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
ParserConfigurationException - if a DocumentBuilder cannot be created which satisfies the
configuration requested.DocumentBuilderFactory.newDocumentBuilder()
public NodeCreateRule(int nodeType,
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_NODEdocumentBuilder - the JAXP DocumentBuilder to use| Method Detail |
|---|
public void begin(String namespaceURI,
String name,
Attributes attributes)
throws Exception
begin in class RulenamespaceURI - 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 element
Exception - indicates a JAXP configuration problem
public void end(String namespace,
String name)
throws Exception
end in class Rulenamespace - 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 otherwise
Exception - if any error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||