下面列出了javax.xml.xpath.XPathFunction#org.jaxen.saxpath.SAXPathException 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void startAllNodeStep(int axis) throws SAXPathException
{
switch (axis)
{
case Axis.CHILD:
if (isAbsolutePath)
{
// addAbsolute(null, null);
// We can always do relative stuff
addRelative(null, null);
}
else
{
addRelative(null, null);
}
break;
case Axis.DESCENDANT_OR_SELF:
query.appendQuery(getArrayList(new DescendantAndSelfStructuredFieldPosition(), new DescendantAndSelfStructuredFieldPosition()));
break;
case Axis.SELF:
query.appendQuery(getArrayList(new SelfAxisStructuredFieldPosition(), new SelfAxisStructuredFieldPosition()));
break;
default:
throw new UnsupportedOperationException();
}
}
public void startNameStep(int axis, String nameSpace, String localName) throws SAXPathException
{
switch (axis)
{
case Axis.CHILD:
if (isAbsolutePath)
{
// addAbsolute(nameSpace, localName);
// we can always do relative stuff
addRelative(nameSpace, localName);
}
else
{
addRelative(nameSpace, localName);
}
break;
default:
throw new UnsupportedOperationException();
}
}
static Query getPathQuery(String path) throws SAXPathException
{
ApplicationContext ac = ApplicationContextHelper.getApplicationContext();
XPathReader reader = new XPathReader();
LuceneXPathHandler handler = new LuceneXPathHandler();
handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService"));
handler.setDictionaryService((DictionaryService) ac.getBean("dictionaryService"));
reader.setXPathHandler(handler);
reader.parse(path);
PathQuery pathQuery = handler.getQuery();
pathQuery.setRepeats(false);
return pathQuery;
}
/**
* @param args String[]
* @throws SAXPathException
*/
public static void main(String[] args) throws SAXPathException
{
XPathReader reader = new XPathReader();
reader.setXPathHandler(new DebugXPathHandler());
reader
.parse("/ns:one[@woof='dog']/two/./../two[functionTest(@a, @b, $woof:woof)]/three/*/four//*/five/six[@exists1 and @exists2]");
}
public void endAdditiveExpr(int op) throws SAXPathException
{
switch (op)
{
case Operator.NO_OP:
break;
case Operator.ADD:
case Operator.SUBTRACT:
throw new UnsupportedOperationException();
default:
throw new UnsupportedOperationException("Unknown operation " + op);
}
}
public void endAndExpr(boolean create) throws SAXPathException
{
if (create)
{
throw new UnsupportedOperationException();
}
}
public void endEqualityExpr(int op) throws SAXPathException
{
switch (op)
{
case Operator.NO_OP:
break;
case Operator.EQUALS:
case Operator.NOT_EQUALS:
throw new UnsupportedOperationException();
default:
throw new UnsupportedOperationException("Unknown operation " + op);
}
}
public void endMultiplicativeExpr(int op) throws SAXPathException
{
switch (op)
{
case Operator.NO_OP:
break;
case Operator.MULTIPLY:
case Operator.DIV:
case Operator.MOD:
throw new UnsupportedOperationException();
default:
throw new UnsupportedOperationException("Unknown operation " + op);
}
}
public void endOrExpr(boolean create) throws SAXPathException
{
if (create)
{
throw new UnsupportedOperationException();
}
}
public void endRelationalExpr(int op) throws SAXPathException
{
switch (op)
{
case Operator.NO_OP:
break;
case Operator.GREATER_THAN:
case Operator.GREATER_THAN_EQUALS:
case Operator.LESS_THAN:
case Operator.LESS_THAN_EQUALS:
throw new UnsupportedOperationException();
default:
throw new UnsupportedOperationException("Unknown operation " + op);
}
}
public void endUnaryExpr(int op) throws SAXPathException
{
switch (op)
{
case Operator.NO_OP:
break;
case Operator.NEGATIVE:
throw new UnsupportedOperationException();
default:
throw new UnsupportedOperationException("Unknown operation " + op);
}
}
public void endUnionExpr(boolean create) throws SAXPathException
{
if (create)
{
throw new UnsupportedOperationException();
}
}
public void startAbsoluteLocationPath() throws SAXPathException
{
if (!isAbsolutePath)
{
throw new IllegalStateException();
}
}
public void endAbsoluteLocationPath() throws SAXPathException
{
System.out.println("End Absolute Location Path");
}
public void endAdditiveExpr(int arg0) throws SAXPathException
{
System.out.println("End Additive Expr: value = " + arg0);
}
public void endAllNodeStep() throws SAXPathException
{
System.out.println("End All Node Step");
}
public void endAndExpr(boolean arg0) throws SAXPathException
{
System.out.println("End And Expr: value = " + arg0);
}
public void endCommentNodeStep() throws SAXPathException
{
System.out.println("End Comment Node Step");
}
public void endEqualityExpr(int arg0) throws SAXPathException
{
System.out.println("End Equality Expr: value = " + arg0);
}
public void endFilterExpr() throws SAXPathException
{
System.out.println("End Filter Expr");
}
public void endFunction() throws SAXPathException
{
System.out.println("End Function");
}
public void endMultiplicativeExpr(int arg0) throws SAXPathException
{
System.out.println("End Multiplicative Expr: value = " + arg0);
}
public void endNameStep() throws SAXPathException
{
System.out.println("End Name Step");
}
public void endOrExpr(boolean arg0) throws SAXPathException
{
System.out.println("End Or Expr: value = " + arg0);
}
public void endPathExpr() throws SAXPathException
{
System.out.println("End Path Expression");
}
public void endPredicate() throws SAXPathException
{
System.out.println("End Predicate");
}
public void endProcessingInstructionNodeStep() throws SAXPathException
{
System.out.println("End Processing Instruction Node Step");
}
public void endRelationalExpr(int arg0) throws SAXPathException
{
System.out.println("End Relational Expr: value = " + arg0);
}
public void endRelativeLocationPath() throws SAXPathException
{
System.out.println("End Relative Location Path");
}
public void endTextNodeStep() throws SAXPathException
{
System.out.println("End Text Node Step");
}