Class DomTripXPath
java.lang.Object
org.jaxen.BaseXPath
eu.maveniverse.domtrip.jaxen.DomTripXPath
- All Implemented Interfaces:
Serializable, org.jaxen.XPath
public class DomTripXPath
extends org.jaxen.BaseXPath
XPath implementation for DomTrip's XML object model.
This class extends Jaxen's BaseXPath to provide full XPath 1.0
evaluation against DomTrip documents. It supports all standard XPath features
including boolean operators, functions, full axis navigation, and union expressions.
Usage:
DomTripXPath xpath = new DomTripXPath("//dependency[scope='test' and groupId='junit']");
List results = xpath.selectNodes(root);
// Type-safe element selection
List<Element> elements = xpath.selectElements(root);
Optional<Element> first = xpath.selectFirstElement(root);
Supported XPath Features (beyond mini-XPath):
- Boolean operators:
and,or - Negation:
not() - Inequality:
!= - String functions:
contains(),starts-with(),string-length() - Union operator:
| - Full axis navigation:
ancestor::,following-sibling::, etc.
- Since:
- 1.3.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDomTripXPath(String xpathExpr) Creates a new XPath expression for DomTrip documents. -
Method Summary
Modifier and TypeMethodDescriptionList<eu.maveniverse.domtrip.Element> selectElements(Object context) Evaluates this expression and returns onlyElementresults.Optional<eu.maveniverse.domtrip.Element> selectFirstElement(Object context) Evaluates this expression and returns the firstElementresult.Methods inherited from class org.jaxen.BaseXPath
addNamespace, booleanValueOf, createFunctionContext, createNamespaceContext, createVariableContext, debug, evaluate, getContext, getContextSupport, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectNodesForContext, selectSingleNode, selectSingleNodeForContext, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, toString
-
Constructor Details
-
DomTripXPath
Creates a new XPath expression for DomTrip documents.- Parameters:
xpathExpr- the XPath 1.0 expression string- Throws:
org.jaxen.JaxenException- if the expression is syntactically invalid
-
-
Method Details
-
selectElements
public List<eu.maveniverse.domtrip.Element> selectElements(Object context) throws org.jaxen.JaxenException Evaluates this expression and returns onlyElementresults.- Parameters:
context- the context node (Element, Document, or other DomTrip node)- Returns:
- list of matching elements
- Throws:
org.jaxen.JaxenException- if evaluation fails
-
selectFirstElement
public Optional<eu.maveniverse.domtrip.Element> selectFirstElement(Object context) throws org.jaxen.JaxenException Evaluates this expression and returns the firstElementresult.- Parameters:
context- the context node (Element, Document, or other DomTrip node)- Returns:
- the first matching element, or empty if none match
- Throws:
org.jaxen.JaxenException- if evaluation fails
-