/** * Determine the data type of the items returned by this expression * * @return the data type */ /*@NotNull*/ public final ItemType getItemType() { final ItemType t1 = getLhsExpression().getItemType(); if (operator == Token.UNION) { ItemType t2 = getRhsExpression().getItemType(); TypeHierarchy th = getConfiguration().getTypeHierarchy(); return Type.getCommonSuperType(t1, t2, th); } else { return t1; } }
/** * Determine the data type of the items returned by this expression * * @return the data type */ /*@NotNull*/ public final ItemType getItemType() { final ItemType t1 = getLhsExpression().getItemType(); if (operator == Token.UNION) { ItemType t2 = getRhsExpression().getItemType(); TypeHierarchy th = getConfiguration().getTypeHierarchy(); return Type.getCommonSuperType(t1, t2, th); } else { return t1; } }
/** * Replace this expression by an expression that returns the same result but without * regard to order * * @param retainAllNodes true if all nodes in the result must be retained; false * if duplicates can be eliminated * @param forStreaming set to true if optimizing for streaming */ @Override public Expression unordered(boolean retainAllNodes, boolean forStreaming) { if (operator == Token.UNION && !forStreaming && operandsAreDisjoint(getConfiguration().getTypeHierarchy())) { // replace union operator by comma operator to avoid cost of sorting into document order. See XMark q7 Block block = new Block(new Expression[]{getLhsExpression(), getRhsExpression()}); ExpressionTool.copyLocationInfo(this, block); return block; } return this; }
/** * Replace this expression by an expression that returns the same result but without * regard to order * * @param retainAllNodes true if all nodes in the result must be retained; false * if duplicates can be eliminated * @param forStreaming set to true if optimizing for streaming */ @Override public Expression unordered(boolean retainAllNodes, boolean forStreaming) { if (operator == Token.UNION && !forStreaming && operandsAreDisjoint(getConfiguration().getTypeHierarchy())) { // replace union operator by comma operator to avoid cost of sorting into document order. See XMark q7 Block block = new Block(new Expression[]{getLhsExpression(), getRhsExpression()}); ExpressionTool.copyLocationInfo(this, block); return block; } return this; }