/** * Make a pattern in the context of this stylesheet element * @param pattern the source text of the pattern * @return the compiled pattern */ public Pattern makePattern(String pattern) throws XPathException { try { return Pattern.make(pattern, staticContext, getPrincipalStylesheet().getExecutable()); } catch (XPathException err) { compileError(err); return new NodeTestPattern(AnyNodeTest.getInstance()); } }
/** * Make a pattern in the context of this stylesheet element * @param pattern the source text of the pattern * @return the compiled pattern */ public Pattern makePattern(String pattern) throws XPathException { try { return Pattern.make(pattern, staticContext, getPrincipalStylesheet().getExecutable()); } catch (XPathException err) { compileError(err); return new NodeTestPattern(AnyNodeTest.getInstance()); } }
/** * Make a pattern in the context of this stylesheet element * * @param pattern the source text of the pattern * @return the compiled pattern */ public Pattern makePattern(String pattern, String attributeName) { try { StaticContext env = getStaticContext(new StructuredQName("", "", attributeName)); Pattern p = Pattern.make(pattern, env, getCompilation().getPackageData()); p.setLocation(allocateLocation()); return p; } catch (XPathException err) { if ("XPST0003".equals(err.getErrorCodeLocalPart())) { err.setErrorCode("XTSE0340"); } compileError(err); NodeTestPattern nsp = new NodeTestPattern(AnyNodeTest.getInstance()); nsp.setLocation(allocateLocation()); return nsp; } }
/** * Prepare (compile) an XSLT pattern for subsequent evaluation. The result is an XPathExpression * object representing a (pseudo-) expression that when evaluated returns a boolean result: true * if the context node matches the pattern, false if it does not. * @param pattern the XSLT pattern to be compiled, supplied as a string * @return an XPathExpression object representing the pattern, wrapped as an expression * @throws XPathException if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared. * @since 9.1 */ public XPathExpression createPattern(String pattern) throws XPathException { Pattern pat = Pattern.make(pattern, staticContext, staticContext.getExecutable()); ExpressionVisitor visitor = ExpressionVisitor.make(staticContext); pat.analyze(visitor, Type.NODE_TYPE); SlotManager map = staticContext.getStackFrameMap(); int slots = map.getNumberOfVariables(); slots = pat.allocateSlots(staticContext, map, slots); PatternSponsor sponsor = new PatternSponsor(pat); XPathExpression xpe = new XPathExpression(this, sponsor); xpe.setStackFrameMap(map, slots); return xpe; }
/** * Make a pattern in the context of this stylesheet element * * @param pattern the source text of the pattern * @return the compiled pattern */ public Pattern makePattern(String pattern, String attributeName) { try { StaticContext env = getStaticContext(new StructuredQName("", "", attributeName)); Pattern p = Pattern.make(pattern, env, getCompilation().getPackageData()); p.setLocation(allocateLocation()); return p; } catch (XPathException err) { if ("XPST0003".equals(err.getErrorCodeLocalPart())) { err.setErrorCode("XTSE0340"); } compileError(err); NodeTestPattern nsp = new NodeTestPattern(AnyNodeTest.getInstance()); nsp.setLocation(allocateLocation()); return nsp; } }
/** * Prepare (compile) an XSLT pattern for subsequent evaluation. The result is an XPathExpression * object representing a (pseudo-) expression that when evaluated returns a boolean result: true * if the context node matches the pattern, false if it does not. * * @param pattern the XSLT pattern to be compiled, supplied as a string * @return an XPathExpression object representing the pattern, wrapped as an expression * @throws XPathException if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared. * @since 9.1 */ /*@NotNull*/ public XPathExpression createPattern(String pattern) throws XPathException { Configuration config = getConfiguration(); Executable exec = new Executable(config); Pattern pat = Pattern.make(pattern, staticContext, new PackageData(config)); ExpressionVisitor visitor = ExpressionVisitor.make(staticContext); pat.typeCheck(visitor, config.makeContextItemStaticInfo(Type.NODE_TYPE, true)); SlotManager map = staticContext.getStackFrameMap(); int slots = map.getNumberOfVariables(); slots = pat.allocateSlots(map, slots); //PatternSponsor sponsor = new PatternSponsor(pat); XPathExpression xpe = new XPathExpression(staticContext, pat, exec); xpe.setStackFrameMap(map, slots); return xpe; }
/** * Prepare (compile) an XSLT pattern for subsequent evaluation. The result is an XPathExpression * object representing a (pseudo-) expression that when evaluated returns a boolean result: true * if the context node matches the pattern, false if it does not. * * @param pattern the XSLT pattern to be compiled, supplied as a string * @return an XPathExpression object representing the pattern, wrapped as an expression * @throws XPathException if the syntax of the expression is wrong, or if it references namespaces, * variables, or functions that have not been declared. * @since 9.1 */ /*@NotNull*/ public XPathExpression createPattern(String pattern) throws XPathException { Configuration config = getConfiguration(); Executable exec = new Executable(config); Pattern pat = Pattern.make(pattern, staticContext, new PackageData(config)); ExpressionVisitor visitor = ExpressionVisitor.make(staticContext); pat.typeCheck(visitor, config.makeContextItemStaticInfo(Type.NODE_TYPE, true)); SlotManager map = staticContext.getStackFrameMap(); int slots = map.getNumberOfVariables(); slots = pat.allocateSlots(map, slots); //PatternSponsor sponsor = new PatternSponsor(pat); XPathExpression xpe = new XPathExpression(staticContext, pat, exec); xpe.setStackFrameMap(map, slots); return xpe; }