/** * Construct an expression that implements the rules of "constructing simple content": * given an expression to select the base sequence, and an expression to compute the separator, * build an (unoptimized) expression to produce the value of the node as a string. * * @param select the expression that selects the base sequence * @param separator the expression that computes the separator * @param env the static context * @return an expression that returns a string containing the string value of the constructed node */ public static Expression makeSimpleContentConstructor(Expression select, Expression separator, StaticContext env) { RetainedStaticContext rsc = select.getLocalRetainedStaticContext(); if (rsc == null) { rsc = env.makeRetainedStaticContext(); } // Merge adjacent text nodes select = AdjacentTextNodeMerger.makeAdjacentTextNodeMerger(select); // Atomize the result select = Atomizer.makeAtomizer(select, null); // Convert each atomic value to a string select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); select.setRetainedStaticContext(rsc); ((AtomicSequenceConverter) select).allocateConverterStatically(env.getConfiguration(), false); // Join the resulting strings with a separator if (select.getCardinality() != StaticProperty.EXACTLY_ONE) { select = SystemFunction.makeCall("string-join", rsc, select, separator); } // All that's left for the instruction to do is to construct the right kind of node return select; }
/** * Construct an expression that implements the rules of "constructing simple content": * given an expression to select the base sequence, and an expression to compute the separator, * build an (unoptimized) expression to produce the value of the node as a string. * * @param select the expression that selects the base sequence * @param separator the expression that computes the separator * @param env the static context * @return an expression that returns a string containing the string value of the constructed node */ public static Expression makeSimpleContentConstructor(Expression select, Expression separator, StaticContext env) { RetainedStaticContext rsc = select.getLocalRetainedStaticContext(); if (rsc == null) { rsc = env.makeRetainedStaticContext(); } // Merge adjacent text nodes select = AdjacentTextNodeMerger.makeAdjacentTextNodeMerger(select); // Atomize the result select = Atomizer.makeAtomizer(select); // Convert each atomic value to a string select = new AtomicSequenceConverter(select, BuiltInAtomicType.STRING); select.setRetainedStaticContext(rsc); ((AtomicSequenceConverter) select).allocateConverterStatically(env.getConfiguration(), false); // Join the resulting strings with a separator if (select.getCardinality() != StaticProperty.EXACTLY_ONE) { select = SystemFunction.makeCall("string-join", rsc, select, separator); } // All that's left for the instruction to do is to construct the right kind of node return select; }