/** * Type-check the pattern. * * @param visitor the expression visitor * @param contextItemType the type of the context item at the point where the pattern * is defined. Set to null if it is known that the context item is undefined. * @return the optimised Pattern */ @Override public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { wrappedPattern = wrappedPattern.typeCheck(visitor, contextItemType); return this; }
/** * Type-check the pattern. * * @param visitor the expression visitor * @param contextItemType the type of the context item at the point where the pattern * is defined. Set to null if it is known that the context item is undefined. * @return the optimised Pattern */ @Override public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { wrappedPattern = wrappedPattern.typeCheck(visitor, contextItemType); return this; }
/** * Type-check the pattern. * This is only needed for patterns that contain variable references or function calls. * * @return the optimised Pattern */ public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { mustBeNodePattern(p1); p1 = p1.typeCheck(visitor, contextItemType); mustBeNodePattern(p2); p2 = p2.typeCheck(visitor, contextItemType); return this; }
/** * Type-check the pattern. * This is only needed for patterns that contain variable references or function calls. * * @return the optimised Pattern */ public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { mustBeNodePattern(p1); p1 = p1.typeCheck(visitor, contextItemType); mustBeNodePattern(p2); p2 = p2.typeCheck(visitor, contextItemType); return this; }
try { return PatternMaker.fromExpression(equivalentExpr, config, true) .typeCheck(visitor, defaultInfo); } catch (XPathException err) {
try { return PatternMaker.fromExpression(equivalentExpr, config, true) .typeCheck(visitor, defaultInfo); } catch (XPathException err) {
/** * Type-check the pattern, performing any type-dependent optimizations. * * @param visitor an expression visitor * @param contextItemType the type of the context item at the point where the pattern appears * @return the optimised Pattern */ public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { basePattern = basePattern.typeCheck(visitor, contextItemType); upperPattern = upperPattern.typeCheck(visitor, contextItemType); if (upwardsAxis == AxisInfo.PARENT) { ItemType type = basePattern.getItemType(); if (type instanceof NodeTest) { // Check that this step in the pattern makes sense in the context of the parent step AxisExpression step; if (type.getPrimitiveType() == Type.ATTRIBUTE) { step = new AxisExpression(AxisInfo.ATTRIBUTE, (NodeTest) type); } else { step = new AxisExpression(AxisInfo.CHILD, (NodeTest) type); } ExpressionTool.copyLocationInfo(this, step); Expression exp = step.typeCheck(visitor, visitor.getConfiguration().makeContextItemStaticInfo(upperPattern.getItemType(), false)); refinedItemType = exp.getItemType(); } } testUpperPatternFirst = upperPattern.getCost() < basePattern.getCost(); return this; }
/** * Type-check the pattern, performing any type-dependent optimizations. * * @param visitor an expression visitor * @param contextItemType the type of the context item at the point where the pattern appears * @return the optimised Pattern */ public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { basePattern = basePattern.typeCheck(visitor, contextItemType); upperPattern = upperPattern.typeCheck(visitor, contextItemType); if (upwardsAxis == AxisInfo.PARENT) { ItemType type = basePattern.getItemType(); if (type instanceof NodeTest) { // Check that this step in the pattern makes sense in the context of the parent step AxisExpression step; if (type.getPrimitiveType() == Type.ATTRIBUTE) { step = new AxisExpression(AxisInfo.ATTRIBUTE, (NodeTest) type); } else { step = new AxisExpression(AxisInfo.CHILD, (NodeTest) type); } ExpressionTool.copyLocationInfo(this, step); Expression exp = step.typeCheck(visitor, visitor.getConfiguration().makeContextItemStaticInfo(upperPattern.getItemType(), false)); refinedItemType = exp.getItemType(); } } testUpperPatternFirst = upperPattern.getCost() < basePattern.getCost(); return this; }
/** * Type-check the pattern. * * @param visitor the expression visitor * @param contextItemType the type of the context item at the point where the pattern * is defined. Set to null if it is known that the context item is undefined. * @return the optimised Pattern */ @Override public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { basePatternOp.setChildExpression(getBasePattern().typeCheck(visitor, contextItemType)); ContextItemStaticInfo cit = visitor.getConfiguration().makeContextItemStaticInfo( getBasePattern().getItemType(), false); predicateOp.setChildExpression(getPredicate().typeCheck(visitor, cit)); return this; }
/** * Type-check the pattern. * * @param visitor the expression visitor * @param contextItemType the type of the context item at the point where the pattern * is defined. Set to null if it is known that the context item is undefined. * @return the optimised Pattern */ @Override public Pattern typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { basePatternOp.setChildExpression(getBasePattern().typeCheck(visitor, contextItemType)); ContextItemStaticInfo cit = visitor.getConfiguration().makeContextItemStaticInfo( getBasePattern().getItemType(), false); predicateOp.setChildExpression(getPredicate().typeCheck(visitor, cit)); return this; }
/** * 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; }
FilterExpression fe = new FilterExpression(ae, positionExpr); return PatternMaker.fromExpression(fe, config, true) .typeCheck(visitor, contextInfo);
ExpressionTool.copyLocationInfo(match, match2); match2.setOriginalText(match.toString()); match2 = match2.typeCheck(visitor, info); match1 = match2;
FilterExpression fe = new FilterExpression(ae, positionExpr); return PatternMaker.fromExpression(fe, config, true) .typeCheck(visitor, contextInfo);
ExpressionTool.copyLocationInfo(match, match2); match2.setOriginalText(match.toString()); match2 = match2.typeCheck(visitor, info); match1 = match2;
pattern = pattern.typeCheck(makeExpressionVisitor(), getConfiguration().makeContextItemStaticInfo(cit, true)); boolean usesCurrent = false;
pattern = pattern.typeCheck(makeExpressionVisitor(), getConfiguration().makeContextItemStaticInfo(cit, true)); boolean usesCurrent = false;