org.apache.xpath.compiler.XPathParser Java Examples
The following examples show how to use
org.apache.xpath.compiler.XPathParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XPath.java From j2objc with Apache License 2.0 | 5 votes |
/** * Construct an XPath object. * * (Needs review -sc) This method initializes an XPathParser/ * Compiler and compiles the expression. * @param exprString The XPath expression. * @param locator The location of the expression, may be null. * @param prefixResolver A prefix resolver to use to resolve prefixes to * namespace URIs. * @param type one of {@link #SELECT} or {@link #MATCH}. * @param errorListener The error listener, or null if default should be used. * * @throws javax.xml.transform.TransformerException if syntax or other error. */ public XPath( String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type, ErrorListener errorListener) throws javax.xml.transform.TransformerException { initFunctionTable(); if(null == errorListener) errorListener = new org.apache.xml.utils.DefaultErrorHandler(); m_patternString = exprString; XPathParser parser = new XPathParser(errorListener, locator); Compiler compiler = new Compiler(errorListener, locator, m_funcTable); if (SELECT == type) parser.initXPath(compiler, exprString, prefixResolver); else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver); else throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type); // System.out.println("----------------"); Expression expr = compiler.compile(0); // System.out.println("expr: "+expr); this.setExpression(expr); if((null != locator) && locator instanceof ExpressionNode) { expr.exprSetParent((ExpressionNode)locator); } }
Example #2
Source File: XPath.java From j2objc with Apache License 2.0 | 5 votes |
/** * Construct an XPath object. * * (Needs review -sc) This method initializes an XPathParser/ * Compiler and compiles the expression. * @param exprString The XPath expression. * @param locator The location of the expression, may be null. * @param prefixResolver A prefix resolver to use to resolve prefixes to * namespace URIs. * @param type one of {@link #SELECT} or {@link #MATCH}. * @param errorListener The error listener, or null if default should be used. * * @throws javax.xml.transform.TransformerException if syntax or other error. */ public XPath( String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type, ErrorListener errorListener, FunctionTable aTable) throws javax.xml.transform.TransformerException { m_funcTable = aTable; if(null == errorListener) errorListener = new org.apache.xml.utils.DefaultErrorHandler(); m_patternString = exprString; XPathParser parser = new XPathParser(errorListener, locator); Compiler compiler = new Compiler(errorListener, locator, m_funcTable); if (SELECT == type) parser.initXPath(compiler, exprString, prefixResolver); else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver); else throw new RuntimeException(XSLMessages.createXPATHMessage( XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type); // System.out.println("----------------"); Expression expr = compiler.compile(0); // System.out.println("expr: "+expr); this.setExpression(expr); if((null != locator) && locator instanceof ExpressionNode) { expr.exprSetParent((ExpressionNode)locator); } }
Example #3
Source File: AVTPartXPath.java From j2objc with Apache License 2.0 | 3 votes |
/** * Construct a simple AVT part. * * @param val A pure string section of an AVT. * @param nsNode An object which can be used to determine the * Namespace Name (URI) for any Namespace prefix used in the XPath. * Usually this is based on the context where the XPath was specified, * such as a node within a Stylesheet. * @param xpathProcessor XPath parser * @param factory XPath factory * @param liaison An XPathContext object, providing infomation specific * to this invocation and this thread. Maintains SAX output state, * variables, error handler and so on, so the transformation/XPath * object itself can be simultaneously invoked from multiple threads. * * @throws javax.xml.transform.TransformerException * TODO: Fix or remove this unused c'tor. */ public AVTPartXPath( String val, org.apache.xml.utils.PrefixResolver nsNode, XPathParser xpathProcessor, XPathFactory factory, XPathContext liaison) throws javax.xml.transform.TransformerException { m_xpath = new XPath(val, null, nsNode, XPath.SELECT, liaison.getErrorListener()); }