Package eu.maveniverse.domtrip.jaxen
Class DomTripXPath
- java.lang.Object
-
- org.jaxen.BaseXPath
-
- eu.maveniverse.domtrip.jaxen.DomTripXPath
-
- All Implemented Interfaces:
java.io.Serializable,org.jaxen.XPath
public class DomTripXPath extends org.jaxen.BaseXPathXPath implementation for DomTrip's XML object model.This class extends Jaxen's
BaseXPathto 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:
XPath,DomTripNavigator, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DomTripXPath(java.lang.String xpathExpr)Creates a new XPath expression for DomTrip documents.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<eu.maveniverse.domtrip.Element>selectElements(java.lang.Object context)Evaluates this expression and returns onlyElementresults.java.util.Optional<eu.maveniverse.domtrip.Element>selectFirstElement(java.lang.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 Detail
-
DomTripXPath
public DomTripXPath(java.lang.String xpathExpr) throws org.jaxen.JaxenExceptionCreates 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 Detail
-
selectElements
public java.util.List<eu.maveniverse.domtrip.Element> selectElements(java.lang.Object context) throws org.jaxen.JaxenExceptionEvaluates 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 java.util.Optional<eu.maveniverse.domtrip.Element> selectFirstElement(java.lang.Object context) throws org.jaxen.JaxenExceptionEvaluates 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
-
-