Class PTBXPath

  extended byorg.jaxen.BaseXPath
      extended byedu.upenn.cis.ptb.xpath.PTBXPath
All Implemented Interfaces:, org.jaxen.XPath

public class PTBXPath
extends org.jaxen.BaseXPath

XPath expression providing access to the additional functions.

This documentation has changed since v0.2.3.

The following syntactic shortenings are supported:
Standard XPathShort Form
child::NP >::NP
parent::NP <::NP
descendant::NP >>::NP
descendant-or-self::NP =>>::NP
ancestor-or-self::NP <<=::NP
following::NP ->::NP
preceding::NP <-::NP
preceding-sibling::NP <$::NP

All the standard functions and axes should work as expected. Here are some simple Xpath queries:

  =>>::NP - selects all the nodes with constituent label NP

  =>>::S[contains(@roles,"TPC")] - selects all the nodes with constituent label S, and
  role TPC.

  =>>::John[->::Mary] - selects all the nodes with label John (terminals) 
  which are followed by nodes with label Mary. 

  =>>::John/->::Mary - to select the nodes with label Mary in the query

The additional functions in this package are for the LPath extensions (Bird et al). Nested function calls needs some extra syntax, since XPath 1.0 doesn't really allow recursion.

For example, consider a query to select, within a VP, all NP nodes that immediately follow a VB that is a child of the VP. What we want is roughly:

  subtree(>>::VP, 'i-foll(>::VB,'=::NP')')
However this has embedded quotes which is not allowed. For this reason, quotes can be replaced by curly braces.
 subtree(>>::VP, {i-foll(>::VB,{=::NP})})

See Also:
Serialized Form

Field Summary
protected static java.util.WeakHashMap fEscapedExprMap
Constructor Summary
PTBXPath(java.lang.String xpathExpr, org.jaxen.Navigator nav)
          Creates a new instance of PTBXPath
Method Summary
static java.lang.String createExpression(java.lang.String prefix, java.lang.String functionName, java.lang.String xpathStr, java.lang.String selectorStr)
          Convenience method for creating recursive expressions.
protected  org.jaxen.FunctionContext createFunctionContext()
protected  org.jaxen.NamespaceContext createNamespaceContext()
static java.lang.String desugarExpr(java.lang.String xpathExpr)
static java.lang.String unEscapeExpr(java.lang.String xpathStr)
Methods inherited from class org.jaxen.BaseXPath
addNamespace, booleanValueOf, createVariableContext, debug, evaluate, getContext, getContextSupport, getFunctionContext, getNamespaceContext, getNavigator, getRootExpr, getVariableContext, numberValueOf, selectNodes, selectNodesForContext, selectSingleNode, selectSingleNodeForContext, setFunctionContext, setNamespaceContext, setVariableContext, stringValueOf, toString, valueOf
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Field Detail


protected static java.util.WeakHashMap fEscapedExprMap
Constructor Detail


public PTBXPath(java.lang.String xpathExpr,
                org.jaxen.Navigator nav)
         throws org.jaxen.JaxenException
Creates a new instance of PTBXPath

Method Detail


protected org.jaxen.FunctionContext createFunctionContext()


protected org.jaxen.NamespaceContext createNamespaceContext()


public static java.lang.String desugarExpr(java.lang.String xpathExpr)


public static java.lang.String createExpression(java.lang.String prefix,
                                                java.lang.String functionName,
                                                java.lang.String xpathStr,
                                                java.lang.String selectorStr)
Convenience method for creating recursive expressions. Using this makes sense only if the functions are one of immediately-following, immediately-preceding, or subtree, in order to embed them inside each other. See the class level docs for an example of use.


public static java.lang.String unEscapeExpr(java.lang.String xpathStr)