public final class StaxUtils extends Object
StaxUtils contains common utilities to help with XPath evaluation and StAX parsing.| Modifier and Type | Method | Description |
|---|---|---|
static Node |
getCurrentNode(Transformer t,
XMLStreamReader xsr) |
Transforms the node currently under the cursor of the
StAX reader into a DOM
Node. |
static Node |
getXPathAsNode(Node node,
XPath xpath,
String expression) |
Evaluates an XPath and returns the result as a
Node. |
static NodeListIterable |
getXPathAsNodeList(Node node,
XPath xpath,
String expression) |
Evaluates an XPath and returns the result as a
NodeList. |
static Double |
getXPathAsNumber(Node node,
XPath xpath,
String expression) |
Evaluates an XPath and returns the result as a Double.
|
static String |
getXPathAsString(Node node,
XPath xpath,
String expression) |
Evaluates an XPath and returns the result as a String.
|
static void |
normalize(Node node) |
Normalizes the
Node. |
public static Node getCurrentNode(Transformer t, XMLStreamReader xsr)
StAX reader into a DOM
Node.
Note that this method advances the XMLStreamReader. You should check the return value of
XMLStreamReader.getEventType() before making your own progress in the stream.
t - A Transformer to perform the work.xsr - The StAX reader. Must lie at a START_ELEMENT.Node.public static Node getXPathAsNode(Node node, XPath xpath, String expression)
Node.node - The node to run the XPath against.xpath - The XPath evaluator.expression - The expression to query.Node.public static String getXPathAsString(Node node, XPath xpath, String expression)
node - The node to run the XPath against.xpath - The XPath evaluator.expression - The expression to query.public static Double getXPathAsNumber(Node node, XPath xpath, String expression)
node - The node to run the XPath against.xpath - The XPath evaluator.expression - The expression to query.public static NodeListIterable getXPathAsNodeList(Node node, XPath xpath, String expression)
NodeList.node - The node to run the XPath against.xpath - The XPath evaluator.expression - The expression to query.NodeList.public static void normalize(Node node)
Node.
Node.normalize().node - The Node to normalizeCopyright © 2025. All rights reserved.