Class DomTripXPath

  • All Implemented Interfaces:
    java.io.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:
    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 only Element results.
      java.util.Optional<eu.maveniverse.domtrip.Element> selectFirstElement​(java.lang.Object context)
      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 java.lang.Object

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

      • DomTripXPath

        public DomTripXPath​(java.lang.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 Detail

      • selectElements

        public java.util.List<eu.maveniverse.domtrip.Element> selectElements​(java.lang.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 java.util.Optional<eu.maveniverse.domtrip.Element> selectFirstElement​(java.lang.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