edu.upenn.cis.ptb.xpath
Class PTBXPath
java.lang.Object
org.jaxen.BaseXPath
edu.upenn.cis.ptb.xpath.PTBXPath
- All Implemented Interfaces:
- java.io.Serializable, 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 XPath | Short Form |
self::NP | =::NP |
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 |
following-sibling::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
above.
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})})
- Since:
- 0.1
- Version:
- 2
- Author:
- nikhild
- See Also:
- Serialized Form
|
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 |
fEscapedExprMap
protected static java.util.WeakHashMap fEscapedExprMap
PTBXPath
public PTBXPath(java.lang.String xpathExpr,
org.jaxen.Navigator nav)
throws org.jaxen.JaxenException
- Creates a new instance of PTBXPath
createFunctionContext
protected org.jaxen.FunctionContext createFunctionContext()
createNamespaceContext
protected org.jaxen.NamespaceContext createNamespaceContext()
desugarExpr
public static java.lang.String desugarExpr(java.lang.String xpathExpr)
createExpression
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.
unEscapeExpr
public static java.lang.String unEscapeExpr(java.lang.String xpathStr)