/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new AtomicSequenceConverter(getBaseExpression().copy(), requiredItemType); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new AtomicSequenceConverter(getBaseExpression().copy(), requiredItemType); }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression */ public Expression copy() { return new AtomicSequenceConverter(getBaseExpression().copy(), requiredItemType); }
/** * Make a string-join expression that concatenates the string-values of items in * a sequence with intervening spaces. This may be simplified later as a result * of type-checking. * @param exp the base expression, evaluating to a sequence * @param env the static context * @return a call on string-join to create a string containing the * representations of the items in the sequence separated by spaces. */ public static Expression makeStringJoin(Expression exp, StaticContext env) { exp = new Atomizer(exp, env.getConfiguration()); final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); ItemType t = exp.getItemType(th); if (!t.equals(BuiltInAtomicType.STRING) && !t.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } StringJoin fn = (StringJoin)SystemFunction.makeSystemFunction( "string-join", new Expression[]{exp, new StringLiteral(StringValue.SINGLE_SPACE)}); ExpressionTool.copyLocationInfo(exp, fn); return fn; }
/** * Make a string-join expression that concatenates the string-values of items in * a sequence with intervening spaces. This may be simplified later as a result * of type-checking. * @param exp the base expression, evaluating to a sequence * @param env the static context * @return a call on string-join to create a string containing the * representations of the items in the sequence separated by spaces. */ public static Expression makeStringJoin(Expression exp, StaticContext env) { exp = new Atomizer(exp, env.getConfiguration()); final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); ItemType t = exp.getItemType(th); if (!t.equals(BuiltInAtomicType.STRING) && !t.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } StringJoin fn = (StringJoin)SystemFunction.makeSystemFunction( "string-join", new Expression[]{exp, new StringLiteral(StringValue.SINGLE_SPACE)}); ExpressionTool.copyLocationInfo(exp, fn); return fn; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variables that need to be re-bound */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { AtomicSequenceConverter atomicConverter = new AtomicSequenceConverter(getBaseExpression().copy(rebindings), requiredItemType); ExpressionTool.copyLocationInfo(this, atomicConverter); atomicConverter.setConverter(converter); atomicConverter.setRoleDiagnostic(getRoleDiagnostic()); return atomicConverter; }
/** * Copy an expression. This makes a deep copy. * * @return the copy of the original expression * @param rebindings variables that need to be re-bound */ /*@NotNull*/ public Expression copy(RebindingMap rebindings) { AtomicSequenceConverter atomicConverter = new AtomicSequenceConverter(getBaseExpression().copy(rebindings), requiredItemType); ExpressionTool.copyLocationInfo(this, atomicConverter); atomicConverter.setConverter(converter); atomicConverter.setRoleDiagnostic(getRoleDiagnostic()); return atomicConverter; }
/** * Make a string-join expression that concatenates the string-values of items in * a sequence with intervening spaces. This may be simplified later as a result * of type-checking. * * @param exp the base expression, evaluating to a sequence * @param env the static context * @return a call on string-join to create a string containing the * representations of the items in the sequence separated by spaces. */ /*@Nullable*/ public static Expression makeStringJoin(Expression exp, /*@NotNull*/ StaticContext env) { exp = Atomizer.makeAtomizer(exp, null); ItemType t = exp.getItemType(); if (!t.equals(BuiltInAtomicType.STRING) && !t.equals(BuiltInAtomicType.UNTYPED_ATOMIC)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) exp).allocateConverterStatically(env.getConfiguration(), false); } if (exp.getCardinality() == StaticProperty.EXACTLY_ONE) { return exp; } else { RetainedStaticContext rsc = new RetainedStaticContext(env); Expression fn = SystemFunction.makeCall("string-join", rsc, exp, new StringLiteral(StringValue.SINGLE_SPACE)); ExpressionTool.copyLocationInfo(exp, fn); return fn; } }
public Expression processValueOf(Expression select, Configuration config) { TypeHierarchy th = config.getTypeHierarchy(); if (!select.getItemType().isPlainType()) { select = Atomizer.makeAtomizer(select, null); } if (Cardinality.allowsMany(select.getCardinality())) { select = FirstItemExpression.makeFirstItemExpression(select); } if (!th.isSubType(select.getItemType(), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) select).allocateConverterStatically(config, false); } return select; }
public Expression processValueOf(Expression select, Configuration config) { TypeHierarchy th = config.getTypeHierarchy(); if (!select.getItemType().isPlainType()) { select = Atomizer.makeAtomizer(select); } if (Cardinality.allowsMany(select.getCardinality())) { select = FirstItemExpression.makeFirstItemExpression(select); } if (!th.isSubType(select.getItemType(), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) select).allocateConverterStatically(config, false); } return select; }
private static Expression makePromoter(Expression exp, Converter converter, BuiltInAtomicType type) { ConversionRules rules = exp.getConfiguration().getConversionRules(); converter.setConversionRules(rules); if (exp instanceof Literal && ((Literal) exp).getValue() instanceof AtomicValue) { ConversionResult result = converter.convert((AtomicValue) ((Literal) exp).getValue()); if (result instanceof AtomicValue) { Literal converted = Literal.makeLiteral((AtomicValue) result, exp); ExpressionTool.copyLocationInfo(exp, converted); return converted; } } AtomicSequenceConverter asc = new AtomicSequenceConverter(exp, type); asc.setConverter(converter); ExpressionTool.copyLocationInfo(exp, asc); return asc; }
private static Expression makePromoter(Expression exp, Converter converter, BuiltInAtomicType type) { ConversionRules rules = exp.getConfiguration().getConversionRules(); converter.setConversionRules(rules); if (exp instanceof Literal && ((Literal) exp).getValue() instanceof AtomicValue) { ConversionResult result = converter.convert((AtomicValue) ((Literal) exp).getValue()); if (result instanceof AtomicValue) { Literal converted = Literal.makeLiteral((AtomicValue) result, exp); ExpressionTool.copyLocationInfo(exp, converted); return converted; } } AtomicSequenceConverter asc = new AtomicSequenceConverter(exp, type); asc.setConverter(converter); ExpressionTool.copyLocationInfo(exp, asc); return asc; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ public static Expression makeFirstItem(Expression exp, StaticContext env) { final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType(th).isAtomicType()) { exp = new Atomizer(exp, env.getConfiguration()); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = new FirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(th), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); } return exp; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ /*@NotNull*/ public static Expression makeFirstItem(Expression exp, StaticContext env) { if (Literal.isEmptySequence(exp)) { return exp; } final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType().isPlainType()) { exp = Atomizer.makeAtomizer(exp, null); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = FirstItemExpression.makeFirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) exp).allocateConverterStatically(env.getConfiguration(), false); } return exp; }
/** * The typeCheck() method is called in XQuery, where node constructors * are implemented as Expressions. In this case the required type for the * select expression is a single string. * @param visitor an expression visitor * @return the rewritten expression * @throws XPathException if any static errors are found in this expression * or any of its children */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { localTypeCheck(visitor, contextItemType); if (select != null) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); select = visitor.typeCheck(select, contextItemType); if (!select.getItemType(th).isAtomicType()) { select = new Atomizer(select, visitor.getConfiguration()).simplify(visitor); } if (!th.isSubType(select.getItemType(th), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); } adoptChildExpression(select); } return this; }
/** * The typeCheck() method is called in XQuery, where node constructors * are implemented as Expressions. In this case the required type for the * select expression is a single string. * @param visitor an expression visitor * @return the rewritten expression * @throws XPathException if any static errors are found in this expression * or any of its children */ public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { localTypeCheck(visitor, contextItemType); if (select != null) { final TypeHierarchy th = visitor.getConfiguration().getTypeHierarchy(); select = visitor.typeCheck(select, contextItemType); if (!select.getItemType(th).isAtomicType()) { select = new Atomizer(select, visitor.getConfiguration()).simplify(visitor); } if (!th.isSubType(select.getItemType(th), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); } adoptChildExpression(select); } return this; }
/** * Make an expression that extracts the first item of a sequence, after atomization */ /*@NotNull*/ public static Expression makeFirstItem(Expression exp, StaticContext env) { if (Literal.isEmptySequence(exp)) { return exp; } final TypeHierarchy th = env.getConfiguration().getTypeHierarchy(); if (!exp.getItemType().isPlainType()) { exp = Atomizer.makeAtomizer(exp); } if (Cardinality.allowsMany(exp.getCardinality())) { exp = FirstItemExpression.makeFirstItemExpression(exp); } if (!th.isSubType(exp.getItemType(), BuiltInAtomicType.STRING)) { exp = new AtomicSequenceConverter(exp, BuiltInAtomicType.STRING); ((AtomicSequenceConverter) exp).allocateConverterStatically(env.getConfiguration(), false); } return exp; }
public Expression compile(Executable exec) throws XPathException { final TypeHierarchy th = getConfiguration().getTypeHierarchy(); if (separator == null && select != null && backwardsCompatibleModeIsEnabled()) { if (!select.getItemType(th).isAtomicType()) { select = new Atomizer(select, getStaticContext().getConfiguration()); } if (Cardinality.allowsMany(select.getCardinality())) { select = new FirstItemExpression(select); } if (!th.isSubType(select.getItemType(th), BuiltInAtomicType.STRING)) { select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); } } else { if (separator == null) { if (select == null) { separator = new StringLiteral(StringValue.EMPTY_STRING); } else { separator = new StringLiteral(StringValue.SINGLE_SPACE); } } } ValueOf inst = new ValueOf(select, disable, false); compileContent(exec, inst, separator); return inst; }