Package net.sf.saxon.instruct

Examples of net.sf.saxon.instruct.Block


                base = new AxisExpression(Axis.DESCENDANT, NodeKindTest.makeNodeKindTest(kind));
                break;

            case Type.NODE:
                Expression allChildren = new AxisExpression(Axis.DESCENDANT, NodeKindTest.ELEMENT);
                Block block = new Block();
                Expression[] union = {new ContextItemExpression(),
                                      new AxisExpression(Axis.ATTRIBUTE, AnyNodeTest.getInstance())};
                block.setChildren(union);
                base = new PathExpression(allChildren, block);
                break;

            case Type.NAMESPACE:
               throw new UnsupportedOperationException("Patterns can't match namespace nodes");
View Full Code Here


                return Closure.make(tail, context, ref);
            }

            case SHARED_APPEND_EXPRESSION: {
                if (exp instanceof Block) {
                    Block block = (Block)exp;
                    Expression base = block.getChildren()[0];
                    Value baseVal;
                    if (base instanceof Literal) {
                        baseVal = ((Literal)base).getValue();
                    } else if (base instanceof VariableReference) {
                        baseVal = Value.asValue(evaluate(base, EVALUATE_VARIABLE, context, ref));
                        if (baseVal instanceof MemoClosure && ((MemoClosure)baseVal).isFullyRead()) {
                            baseVal = ((MemoClosure)baseVal).materialize();
                        }
                    } else {
                        throw new AssertionError("base of shared append expression is of class " + base.getClass());
                    }
                    if (baseVal instanceof ShareableSequence && ((ShareableSequence)baseVal).isShareable()) {
                        List list = ((ShareableSequence)baseVal).getList();
                        SequenceIterator iter = block.getChildren()[1].iterate(context);
                        while (true) {
                            Item i = iter.next();
                            if (i == null) {
                                break;
                            }
                            list.add(i);
                        }
                        return new ShareableSequence(list);
                    } else {
                        List list = new ArrayList(20);
                        SequenceIterator iter = baseVal.iterate();
                        while (true) {
                            Item i = iter.next();
                            if (i == null) {
                                break;
                            }
                            list.add(i);
                        }
                        iter = block.getChildren()[1].iterate(context);
                        while (true) {
                            Item i = iter.next();
                            if (i == null) {
                                break;
                            }
View Full Code Here

        // Convert @*|node() into @*,node() to eliminate the sorted merge operation
        if (operator == Token.UNION && operand0 instanceof AxisExpression && operand1 instanceof AxisExpression) {
            AxisExpression a0 = (AxisExpression)operand0;
            AxisExpression a1 = (AxisExpression)operand1;
            if (a0.getAxis() == Axis.ATTRIBUTE && a1.getAxis() == Axis.CHILD) {
                Block b = new Block();
                b.setChildren(new Expression[]{operand0, operand1});
                return b;
            } else if (a1.getAxis() == Axis.ATTRIBUTE && a0.getAxis() == Axis.CHILD) {
                Block b = new Block();
                b.setChildren(new Expression[]{operand1, operand0});
                return b;
            }
        }
        return this;
    }
View Full Code Here

        checkWithinTemplate();
        test = typeCheck("test", test);
    }

    public Expression compile(Executable exec) throws TransformerConfigurationException {
        Block block = new Block();
        compileChildren(exec, block, true);
        try {
            While w = new While(test, block.simplify(getStaticContext()));
            ExpressionTool.makeParentReferences(w);
            return w;
        } catch (XPathException e) {
            compileError(e);
            return null;
View Full Code Here

        } else if (ending != null) {
            algorithm = ForEachGroup.GROUP_ENDING;
            key = ending;
        }

        Block action = new Block();
        compileChildren(exec, action, true);
        try {
            ForEachGroup inst = new ForEachGroup(
                                        select,
                                        action.simplify(getStaticContext()),
                                        algorithm,
                                        key,
                                        collator,
                                        makeSortKeys() );
            ExpressionTool.makeParentReferences(inst);
View Full Code Here

        }

    }

    public Expression compile(Executable exec) throws TransformerConfigurationException {
        Block matchingBlock = null;
        if (matching != null) {
            matchingBlock = new Block();
            matchingBlock.setLocationId(allocateLocationId(getSystemId(), matching.getLineNumber()));
            matching.compileChildren(exec, matchingBlock, true);
        }

        Block nonMatchingBlock = null;
        if (nonMatching != null) {
            nonMatchingBlock = new Block();
            nonMatchingBlock.setLocationId(allocateLocationId(getSystemId(), nonMatching.getLineNumber()));
            nonMatching.compileChildren(exec, nonMatchingBlock, true);
        }

        try {
            AnalyzeString anal = new AnalyzeString(
                                     select,
                                     regex,
                                     flags,
                                     (matching==null ? null : matchingBlock.simplify(matching.getStaticContext())),
                                     (nonMatching==null ? null : nonMatchingBlock.simplify(nonMatching.getStaticContext())),
                                     pattern );
            ExpressionTool.makeParentReferences(anal);
            return anal;
        } catch (XPathException e) {
            compileError(e);
View Full Code Here

        return null;
    }

    public Expression compile(Executable exec) throws TransformerConfigurationException {
        if (select == null) {
            Block body = new Block();
            compileChildren(exec, body, true);
            try {
                sortKeyDefinition.setSortKey(new Atomizer(body.simplify(getStaticContext())));
            } catch (XPathException e) {
                compileError(e);
            }
        }
        try {
View Full Code Here

        if (select != null) {
            SortExpression sortedSequence = new SortExpression(select, sortKeys);
            ExpressionTool.makeParentReferences(sortedSequence);
            return sortedSequence;
        } else {
            Block body = new Block();
            compileChildren(exec, body, true);
            try {
                SortExpression sortedSequence =  new SortExpression(body.simplify(getStaticContext()), sortKeys);
                ExpressionTool.makeParentReferences(sortedSequence);
                return sortedSequence;
            } catch (XPathException e) {
                compileError(e);
                return null;
View Full Code Here

            }
            collator = (Collator)comp;
        }

        if (use==null) {
            Block body = new Block();
            compileChildren(exec, body, true);
            try {
                use = new Atomizer(body.simplify(getStaticContext()));
            } catch (XPathException e) {
                compileError(e);
            }

            try {
View Full Code Here

            return (Instruction)list.get(0);
        } else {
            // We are getting back one Block for each xsl:fallback element,
            // then we are wrapping these blocks in another Block. This
            // is clumsy, but it's not a commonly-used operation...
            Block block = new Block();
            Instruction[] array = new Instruction[list.size()];
            for (int i=0; i<list.size(); i++) {
                array[i] = (Instruction)list.get(i);
            }
            block.setChildren(array);
            return block;
        }

    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.instruct.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.