Package net.sf.saxon

Examples of net.sf.saxon.Controller


                }
            case ITERATE_METHOD:
                dynamicError("iterate() is not implemented in the subclass " + this.getClass(), context.getController());
                break;
            case PROCESS_METHOD:
                Controller controller = context.getController();
                XPathContext c2 = context.newMinorContext();
                c2.setOrigin(this);
                SequenceOutputter seq = new SequenceOutputter();
                seq.setConfiguration(controller.getConfiguration());
                seq.setDocumentLocator(getExecutable().getLocationMap());
                c2.setTemporaryReceiver(seq);
                process(c2);
                seq.close();
                return seq.getSequence().iterate(context);
View Full Code Here


            NodeInfo prev = (NodeInfo)preceding.next();
            if (prev == null) {
                break;
            }

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

            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 && count!=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();
        }

        SequenceIterator preceding =
            node.iterateAxis(Axis.PRECEDING_OR_ANCESTOR, filter);

        while (true) {
            NodeInfo prev = (NodeInfo)preceding.next();
            if (prev == null) {
                break;
            }
            if (from!=null && from.matches(prev, context)) {
                return num;
            }
            if (count.matches(prev, context)) {
                if (num==1 && memoNode!=null && prev.isSameNodeInfo(memoNode)) {
                    num = memoNumber + 1;
                    break;
                }
                num++;
            }
        }
        if (memoise) {
            Object[] memo = new Object[2];
            memo[0] = node;
            memo[1] = new Integer(num);
            controller.setUserData(inst, "xsl:number", memo);
        }
        return num;
    }
View Full Code Here

    /**
    * Evaluate the variable
    */

    public Value evaluateVariable(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        Bindery b = controller.getBindery();
        boolean wasSupplied = b.useGlobalParameter(getVariableFingerprint(), this);
        if (wasSupplied) {
            return b.getGlobalVariableValue(this);
        } else {
            if (isRequiredParam()) {
View Full Code Here

        }
        return list.iterator();
    }

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();
        Emitter emitter = controller.getMessageEmitter();
        if (emitter==null) {
            emitter = controller.makeMessageEmitter();
        }
        if (emitter.getWriter()==null) {
            emitter.setWriter(new OutputStreamWriter(System.err));
        }
View Full Code Here

    * @return a TailCall to be executed by the caller, always null for this instruction
    */

    public TailCall processLeavingTail(XPathContext context) throws XPathException
    {
        Controller controller = context.getController();
        int nameCode = evaluateNameCode(context);
        if (nameCode == -1) {
            return null;
        }
        SequenceReceiver out = context.getReceiver();
        int opt = options;
        int ann = annotation;

      // we may need to change the namespace prefix if the one we chose is
      // already in use with a different namespace URI: this is done behind the scenes
      // by the Outputter

        String value = expandChildren(context).toString();
        if (schemaType != null) {
            // test whether the value actually conforms to the given type
            try {
                schemaType.validateContent(value, DummyNamespaceResolver.getInstance());
                if (schemaType.isNamespaceSensitive()) {
                    options |= ReceiverOptions.NEEDS_PREFIX_CHECK;
                }
            } catch (ValidationException err) {
                throw new ValidationException("Attribute value " + Err.wrap(value, Err.VALUE) +
                                               " does not match the required type " +
                                               schemaType.getDescription() + ". " +
                                               err.getMessage());
            }
        } else if (validationAction==Validation.STRICT ||
                validationAction==Validation.LAX) {
            long res = controller.getConfiguration().validateAttribute(nameCode,
                                                                         value,
                                                                         validationAction);
            ann = (int)(res & 0xffffffff);
            opt |= (int)(res >> 32);
        }
View Full Code Here

        return null;
    }

    protected int evaluateNameCode(XPathContext context) throws XPathException, XPathException {
        Controller controller = context.getController();
        NamePool pool = controller.getNamePool();

        Item nameValue = attributeName.evaluateItem(context);

        String prefix = null;
        String localName = null;
View Full Code Here

        }   
        return list.iterator();
    }

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        Controller controller = context.getController();

        GroupIterator groupIterator = getGroupIterator(context);

        XPathContextMajor c2 = context.newContext();
        c2.setOrigin(this);
        c2.setCurrentIterator(groupIterator);
        c2.setCurrentGroupIterator(groupIterator);
        c2.setCurrentTemplate(null);

        if (controller.isTracing()) {
            TraceListener listener = controller.getTraceListener();
            while(true) {
                Item item = groupIterator.next();
                if (item == null) break;
                listener.startCurrentItem(item);
                action.process(c2);
View Full Code Here

    * date/time of this transformation run. Two calls within the same
    * transformation will always return the same answer.
    */

    public DateTimeValue(XPathContext context) {
        Controller c = context.getController();
        if (c==null) {
            // non-XSLT environment
            calendar = new GregorianCalendar();
        } else {
            calendar = c.getCurrentDateTime();
        }
        zoneSpecified = true;
    }
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        Controller controller = c.getController();
        AtomicValue content = (AtomicValue)argument[0].evaluateItem(c);
        StringReader sr = new StringReader(content.getStringValue());
        InputSource is = new InputSource(sr);
        is.setSystemId(baseURI);
        SAXSource source = new SAXSource(is);
        source.setSystemId(baseURI);
        Builder b = controller.makeBuilder();
        Stripper s = controller.makeStripper(b);
        try {
            new Sender(controller.getConfiguration()).send(source, s);
            return b.getCurrentDocument();
        } catch (XPathException err) {
            throw new DynamicError(err);
        }
    }
View Full Code Here

TOP

Related Classes of net.sf.saxon.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.