Package client.net.sf.saxon.ce

Examples of client.net.sf.saxon.ce.Controller


                throw new AssertionError(
                        "evaluateItem() is not implemented in the subclass " + getClass());
        } else if ((m & ITERATE_METHOD) != 0) {
            return iterate(context).next();
        } else {
            Controller controller = context.getController();
            XPathContext c2 = context.newMinorContext();
            SequenceOutputter seq = controller.allocateSequenceOutputter(1);
            PipelineConfiguration pipe = controller.makePipelineConfiguration();
            seq.setPipelineConfiguration(pipe);
            c2.setTemporaryReceiver(seq);
            process(c2);
            seq.close();
            Item result = seq.getFirstItem();
View Full Code Here


        if ((m & EVALUATE_METHOD) != 0) {
            return super.iterate(context);
        } else if ((m & ITERATE_METHOD) != 0) {
            throw new AssertionError("iterate");
        } else {
            Controller controller = context.getController();
            XPathContext c2 = context.newMinorContext();
            SequenceOutputter seq = controller.allocateSequenceOutputter(20);
            PipelineConfiguration pipe = controller.makePipelineConfiguration();
            seq.setPipelineConfiguration(pipe);
            c2.setTemporaryReceiver(seq);
            process(c2);
            seq.close();
            return seq.iterate();
View Full Code Here

    * Evaluate the variable
    */

    @Override
    public ValueRepresentation evaluateVariable(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        Bindery b = controller.getBindery();
        boolean wasSupplied;
        try {
            wasSupplied = b.useGlobalParameter(
                    getVariableQName(), getSlotNumber(), getRequiredType(), context);
        } catch (XPathException e) {
View Full Code Here

            same = NodeKindTest.makeNodeKindTest(node.getNodeKind());
        } else {
            same = new NameTest(node);
        }

        Controller controller = (context == null ? null : context.getController());
        AxisIterator preceding = node.iterateAxis(Axis.PRECEDING_SIBLING, same);

        int i = 1;
        while (true) {
            NodeInfo prev = (NodeInfo)preceding.next();
            if (prev == null) {
                break;
            }

            if (controller != null) {
                int memo = controller.getRememberedNumber(prev);
                if (memo > 0) {
                    memo += i;
                    controller.setRememberedNumber(node, memo);
                    return memo;
                }
            }

            i++;
        }

        if (controller != null) {
            controller.setRememberedNumber(node, i);
        }
        return i;
    }
View Full Code Here

    public static int getNumberAny(Expression inst, NodeInfo node, Pattern count,
                                   Pattern from, XPathContext context, boolean hasVariablesInPatterns) throws XPathException {

        NodeInfo memoNode = null;
        int memoNumber = 0;
        Controller controller = context.getController();
        boolean memoise = (!hasVariablesInPatterns) && from==null;
        if (memoise) {
            Object[] memo = (Object[])controller.getUserData(inst, "xsl:number");
            if (memo != null) {
                memoNode = (NodeInfo)memo[0];
                memoNumber = ((Integer)memo[1]).intValue();
            }
        }

        int num = 0;
        if (count == null) {
            if (node.getFingerprint() == -1) {  // unnamed node
                count = new NodeTestPattern(NodeKindTest.makeNodeKindTest(node.getNodeKind()));
            } else {
                count = new NodeTestPattern(new NameTest(node));
            }
            num = 1;
        } else if (count.matches(node, context)) {
            num = 1;
        }

        // We use a special axis invented for the purpose: the union of the preceding and
        // ancestor axes, but in reverse document order

        // Pass part of the filtering down to the axis iterator if possible
        NodeTest filter;
        if (from == null) {
            filter = count.getNodeTest();
        } else if (from.getNodeKind() == Type.ELEMENT && count.getNodeKind() == Type.ELEMENT) {
            filter = NodeKindTest.ELEMENT;
        } else {
            filter = AnyNodeTest.getInstance();
        }

        if (from != null && from.matches(node, context)) {
            return num;
        }

        SequenceIterator preceding =
                node.iterateAxis(Axis.PRECEDING_OR_ANCESTOR, filter);
      
        while (true) {
            NodeInfo prev = (NodeInfo)preceding.next();
            if (prev == null) {
                break;
            }

            if (count.matches(prev, context)) {
                if (num == 1 && memoNode != null && prev.isSameNodeInfo(memoNode)) {
                    num = memoNumber + 1;
                    break;
                }
                num++;
            }

            if (from != null && from.matches(prev, context)) {
                break;
            }
        }

        if (memoise) {
            Object[] memo = new Object[2];
            memo[0] = node;
            memo[1] = Integer.valueOf(num);
            controller.setUserData(inst, "xsl:number", memo);
        }
        return num;
    }
View Full Code Here

     * the current date and time are taken directly from the system clock
     * @return the current xs:dateTime
     */

    public static DateTimeValue getCurrentDateTime(XPathContext context) {
        Controller c;
        if (context == null || (c = context.getController()) == null) {
            // non-XSLT/XQuery environment
            // We also take this path when evaluating compile-time expressions that require an implicit timezone.
            try {
                return DateTimeValue.fromJavaDate(new Date());
            } catch (XPathException e) {
                throw new IllegalStateException();
            }
        } else {
            return c.getCurrentDateTime();
        }
    }
View Full Code Here

     * Construct a new context as a copy of another. The new context is effectively added
     * to the top of a stack, and contains a pointer to the previous context
     */

    public XPathContextMajor newContext() {
        Controller controller = new Controller(config);
        return controller.newXPathContext();
//        notAllowed();
//        return null;
    }
View Full Code Here

     * @param context the dynamic execution context
     * @return either null, or a tail call that the caller must invoke on return
     * @throws net.sf.saxon.trans.XPathException
     */
    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        assert controller != null;
        if (LogConfiguration.loggingIsEnabled() && LogController.traceIsEnabled()) {
          TraceListener listener = LogController.getTraceListener();
        listener.enter(getInstructionInfo(), context);
        child.process(context);
View Full Code Here

        // if there's no namespace - or no namespace support
        if (element == null) {
            element = document.createElement(localName);
        }
        // special case for html element: write to the document node
        Controller controller = pipe.getController();
        if (controller != null && controller.getApiCommand() == APIcommand.UPDATE_HTML
            && (localName.equals("html") || localName.equals("head") || localName.equals("body"))) {
          if (localName.equals("html")){
            element = (Element)document.getFirstChild();
          } else {
            element = (Element)document.getElementsByTagName(localName.toUpperCase()).getItem(0);
View Full Code Here

     * if it is referenced).
     * @param exec the Executable
    */

    public XPathContextMajor(Item item, Executable exec) {
        controller = new Controller(exec.getConfiguration(), exec);
        if (item != null) {
            UnfailingIterator iter = SingletonIterator.makeIterator(item);
            iter.next();
            currentIterator = iter;
            last = new LastValue(1);
View Full Code Here

TOP

Related Classes of client.net.sf.saxon.ce.Controller

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.