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

    Constructors
    Constructor
    Description
    DomTripXPath(String xpathExpr)
    Creates a new XPath expression for DomTrip documents.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<eu.maveniverse.domtrip.Element>
    Evaluates this expression and returns only Element results.
    Optional<eu.maveniverse.domtrip.Element>
    Evaluates this expression and returns the first Element result.

    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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DomTripXPath

      public DomTripXPath(String xpathExpr) throws org.jaxen.JaxenException
      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 only Element results.
      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 first Element result.
      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