/** * Get a UType indicating which kinds of items this Pattern can match. * * @return a UType indicating all the primitive types of item that the pattern can match. */ @Override public UType getUType() { return p1.getUType().intersection(p2.getUType()); }
/** * Get a UType indicating which kinds of items this Pattern can match. * * @return a UType indicating all the primitive types of item that the pattern can match. */ @Override public UType getUType() { return p1.getUType().intersection(p2.getUType()); }
/** * Get the static type of the expression as a UType, following precisely the type * inference rules defined in the XSLT 3.0 specification. * * @param contextItemType the static type of the context item for the expression evaluation * @return the static item type of the expression according to the XSLT 3.0 defined rules */ @Override public UType getStaticUType(UType contextItemType) { // See W3C bug 30032 UType reachable = AxisInfo.getTargetUType(contextItemType, axis); if (test == null) { return reachable; } else { return reachable.intersection(test.getUType()); } }
/** * Get the static type of the expression as a UType, following precisely the type * inference rules defined in the XSLT 3.0 specification. * * @param contextItemType the static type of the context item for the expression evaluation * @return the static item type of the expression according to the XSLT 3.0 defined rules */ @Override public UType getStaticUType(UType contextItemType) { // See W3C bug 30032 UType reachable = AxisInfo.getTargetUType(contextItemType, axis); if (test == null) { return reachable; } else { return reachable.intersection(test.getUType()); } }
/** * Get the corresponding {@link net.sf.saxon.type.UType}. A UType is a union of primitive item * types. * * @return the smallest UType that subsumes this item type */ public UType getUType() { UType u1 = nodetest1.getUType(); UType u2 = nodetest2.getUType(); switch (operator) { case Token.UNION: return u1.union(u2); case Token.INTERSECT: return u1.intersection(u2); case Token.EXCEPT: return u1; default: throw new IllegalArgumentException("Unknown operator in Combined Node Test"); } }
private boolean mayReturnStreamedNodes(Expression exp) { // bug 3465: expressions returning streamed nodes cannot be loop-lifted, // because such nodes must not be bound to a variable // TODO: attempt a more rigorous analysis - see bug 3465 return streaming && !exp.getItemType().getUType().intersection(UType.ANY_NODE).equals(UType.VOID); }
private boolean mayReturnStreamedNodes(Expression exp) { // bug 3465: expressions returning streamed nodes cannot be loop-lifted, // because such nodes must not be bound to a variable // TODO: attempt a more rigorous analysis - see bug 3465 return streaming && !exp.getItemType().getUType().intersection(UType.ANY_NODE).equals(UType.VOID); }
/** * Get the corresponding {@link net.sf.saxon.type.UType}. A UType is a union of primitive item * types. * * @return the smallest UType that subsumes this item type */ public UType getUType() { UType u1 = nodetest1.getUType(); UType u2 = nodetest2.getUType(); switch (operator) { case Token.UNION: return u1.union(u2); case Token.INTERSECT: return u1.intersection(u2); case Token.EXCEPT: return u1; default: throw new IllegalArgumentException("Unknown operator in Combined Node Test"); } }
/** * Given a context item type and an axis, determine the kinds of nodes that can be returned * @param origin the context item type, as a UType representing one or more node kinds * @param axis identifies the axis * @return the set of possible node kinds in the result of the axis expression, as a UType */ public static UType getTargetUType(UType origin, byte axis) { UType resultType = UType.VOID; Set<PrimitiveUType> origins = origin.intersection(UType.ANY_NODE).decompose(); for (PrimitiveUType u : origins) { UType r = axisTransitions.get(makeKey(u, axis)); resultType = resultType.union(r); } return resultType; }
/** * Given a context item type and an axis, determine the kinds of nodes that can be returned * @param origin the context item type, as a UType representing one or more node kinds * @param axis identifies the axis * @return the set of possible node kinds in the result of the axis expression, as a UType */ public static UType getTargetUType(UType origin, byte axis) { UType resultType = UType.VOID; Set<PrimitiveUType> origins = origin.intersection(UType.ANY_NODE).decompose(); for (PrimitiveUType u : origins) { UType r = axisTransitions.get(makeKey(u, axis)); resultType = resultType.union(r); } return resultType; }
/** * Get the static type of the expression as a UType, following precisely the type * inference rules defined in the XSLT 3.0 specification. * * @param contextItemType the static type of the context item * @return the static item type of the expression according to the XSLT 3.0 defined rules */ @Override public UType getStaticUType(UType contextItemType) { UType result = getItemType().getUType(); for (Operand o : operands()) { if (o.getUsage() == OperandUsage.TRANSMISSION) { result = result.intersection(o.getChildExpression().getStaticUType(contextItemType)); } } return result; }
/** * Get the static type of the expression as a UType, following precisely the type * inference rules defined in the XSLT 3.0 specification. * * @param contextItemType the static type of the context item * @return the static item type of the expression according to the XSLT 3.0 defined rules */ @Override public UType getStaticUType(UType contextItemType) { UType result = getItemType().getUType(); for (Operand o : operands()) { if (o.getUsage() == OperandUsage.TRANSMISSION) { result = result.intersection(o.getChildExpression().getStaticUType(contextItemType)); } } return result; }
@Override public AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest) { if (nodeTest.getUType().intersection(UType.TEXT) == UType.VOID || axisNumber == AxisInfo.ATTRIBUTE || axisNumber == AxisInfo.NAMESPACE) { // iteration does not include text nodes, so no stripping needed return new WrappingIterator(node.iterateAxis(axisNumber, nodeTest), this, getParentForAxis(axisNumber)); } else { return new StrippingIterator(node.iterateAxis(axisNumber, nodeTest), getParentForAxis(axisNumber)); } }
@Override public AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest) { if (nodeTest.getUType().intersection(UType.TEXT) == UType.VOID || axisNumber == AxisInfo.ATTRIBUTE || axisNumber == AxisInfo.NAMESPACE) { // iteration does not include text nodes, so no stripping needed return new WrappingIterator(node.iterateAxis(axisNumber, nodeTest), this, getParentForAxis(axisNumber)); } else { return new StrippingIterator(node.iterateAxis(axisNumber, nodeTest), getParentForAxis(axisNumber)); } }
/** * Get the static type of the expression as a UType, following precisely the type * inference rules defined in the XSLT 3.0 specification. * * @return the static item type of the expression according to the XSLT 3.0 defined rules * @param contextItemType the static type of the context item */ @Override public UType getStaticUType(UType contextItemType) { switch (operator) { case Token.UNION: return getLhsExpression().getStaticUType(contextItemType).union(getRhsExpression().getStaticUType(contextItemType)); case Token.INTERSECT: return getLhsExpression().getStaticUType(contextItemType).intersection(getRhsExpression().getStaticUType(contextItemType)); case Token.EXCEPT: default: return getLhsExpression().getStaticUType(contextItemType); } }
/** * Get the static type of the expression as a UType, following precisely the type * inference rules defined in the XSLT 3.0 specification. * * @return the static item type of the expression according to the XSLT 3.0 defined rules * @param contextItemType the static type of the context item */ @Override public UType getStaticUType(UType contextItemType) { switch (operator) { case Token.UNION: return getLhsExpression().getStaticUType(contextItemType).union(getRhsExpression().getStaticUType(contextItemType)); case Token.INTERSECT: return getLhsExpression().getStaticUType(contextItemType).intersection(getRhsExpression().getStaticUType(contextItemType)); case Token.EXCEPT: default: return getLhsExpression().getStaticUType(contextItemType); } }
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { if (resultItemType == null) { resultItemType = computeItemType(visitor.getConfiguration().getTypeHierarchy()); } if (visitor.isOptimizeForStreaming()) { UType type = contextItemType.getItemType().getUType(); if (!type.intersection(MultipleNodeKindTest.LEAF.getUType()).equals(UType.VOID)) { Expression copyOf = new CopyOf( new ContextItemExpression(), false, getValidationAction(), getSchemaType(), false); NodeTest leafTest = new MultipleNodeKindTest(type.intersection(MultipleNodeKindTest.LEAF.getUType())); Expression[] conditions = new Expression[]{ new InstanceOfExpression( new ContextItemExpression(), SequenceType.makeSequenceType(leafTest, StaticProperty.EXACTLY_ONE)), Literal.makeLiteral(BooleanValue.TRUE, this)}; Expression[] actions = new Expression[]{copyOf, this}; Choose choose = new Choose(conditions, actions); ExpressionTool.copyLocationInfo(this, choose); return choose; } } } return exp; }
if (!(getChildExpression(c) instanceof OnEmptyExpr || getChildExpression(c) instanceof OnNonEmptyExpr)) { lastOrdinaryInstruction = c; if (getChildExpression(c).getItemType().getUType().intersection(UType.DOCUMENT.union(UType.TEXT)).equals(UType.VOID)) { int card = getChildExpression(c).getCardinality(); if (!Cardinality.allowsZero(card)) {
public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo contextItemType) throws XPathException { Expression exp = super.optimize(visitor, contextItemType); if (exp == this) { if (resultItemType == null) { resultItemType = computeItemType(visitor.getConfiguration().getTypeHierarchy()); } if (visitor.isOptimizeForStreaming()) { UType type = contextItemType.getItemType().getUType(); if (!type.intersection(MultipleNodeKindTest.LEAF.getUType()).equals(UType.VOID)) { Expression copyOf = new CopyOf( new ContextItemExpression(), false, getValidationAction(), getSchemaType(), false); NodeTest leafTest = new MultipleNodeKindTest(type.intersection(MultipleNodeKindTest.LEAF.getUType())); Expression[] conditions = new Expression[]{ new InstanceOfExpression( new ContextItemExpression(), SequenceType.makeSequenceType(leafTest, StaticProperty.EXACTLY_ONE)), Literal.makeLiteral(BooleanValue.TRUE, this)}; Expression[] actions = new Expression[]{copyOf, this}; Choose choose = new Choose(conditions, actions); ExpressionTool.copyLocationInfo(this, choose); return choose; } } } return exp; }
if (!(getChildExpression(c) instanceof OnEmptyExpr || getChildExpression(c) instanceof OnNonEmptyExpr)) { lastOrdinaryInstruction = c; if (getChildExpression(c).getItemType().getUType().intersection(UType.DOCUMENT.union(UType.TEXT)).equals(UType.VOID)) { int card = getChildExpression(c).getCardinality(); if (!Cardinality.allowsZero(card)) {