All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.saxon.sort.TupleExpression Maven / Gradle / Ivy

Go to download

Provides a basic XSLT 2.0 and XQuery 1.0 processor (W3C Recommendations, January 2007). Command line interfaces and implementations of several Java APIs (DOM, XPath, s9api) are also included.

The newest version!
package net.sf.saxon.sort;

import net.sf.saxon.trace.ExpressionPresenter;
import net.sf.saxon.expr.*;
import net.sf.saxon.om.Item;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.type.ExternalObjectType;
import net.sf.saxon.type.ItemType;
import net.sf.saxon.type.TypeHierarchy;
import net.sf.saxon.value.ObjectValue;
import net.sf.saxon.value.Value;

import java.util.Arrays;
import java.util.Iterator;

/**
 * A tuple expression is an expression that returns a tuple. Specifically,
 * it is a list of n expressions, which are evaluated to create a list of n items.
 * Tuple expressions are used during the evaluation of a FLWR expression. A tuple
 * is not a value within the XPath/XQuery type system, so it is represented as
 * an external object, specifically as a Java array wrapped inside an ObjectValue.
 *
 */
public class TupleExpression extends Expression {

    Expression[] components;
    int[] evaluationModes;

    public TupleExpression(int width) {
        components = new Expression[width];
        evaluationModes = new int[width];
    }

    /**
     * Set the i'th component expression of the tuple
     * @param i identifies the component to set
     * @param exp the component expression
     */

    public void setExpression(int i, Expression exp) {
        components[i] = exp;
        adoptChildExpression(components[i]);
        evaluationModes[i] = ExpressionTool.UNDECIDED;
    }

    /**
     * Get the component expressions
     * @return the component expressions, as an array
     */

    public Expression[] getComponents() {
        return components;
    }

    public Expression simplify(ExpressionVisitor visitor) throws XPathException {
        for (int i=0; i
     * 

This method is called after all references to functions and variables have been resolved * to the declaration of the function or variable, and after all type checking has been done.

* * @param visitor an expression visitor * @param contextItemType the static type of "." at the point where this expression is invoked. * The parameter is set to null if it is known statically that the context item will be undefined. * If the type of the context item is not known statically, the argument is set to * {@link net.sf.saxon.type.Type#ITEM_TYPE} * @return the original expression, rewritten if appropriate to optimize execution * @throws XPathException if an error is discovered during this phase * (typically a type error) */ public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException { for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy