Package net.sf.saxon.om

Examples of net.sf.saxon.om.NodeInfo


            DynamicError e = new DynamicError("Cannot call xsl:next-match when context item is not a node");
            e.setXPathContext(context);
            e.setErrorCode("XT0565");
            throw e;
        }
        NodeInfo node = (NodeInfo)currentItem;
        Template nh = controller.getRuleManager().getNextMatchHandler(node, mode, currentTemplate, context);

    if (nh==null) {             // use the default action for the node
            ApplyTemplates.defaultAction(node, params, tunnels, context);
        } else {
View Full Code Here


            DynamicError e = new DynamicError("Cannot call xsl:apply-imports when context item is not a node");
            e.setXPathContext(context);
            e.setErrorCode("XT0565");
            throw e;
        }
        NodeInfo node = (NodeInfo)currentItem;
        Template nh = controller.getRuleManager().getTemplateRule(node, mode, min, max, context);

    if (nh==null) {             // use the default action for the node
            ApplyTemplates.defaultAction(node, params, tunnels, context);
        } else {
View Full Code Here

    public void validate() throws TransformerConfigurationException {
        checkWithinTemplate();

        AxisIterator kids = iterateAxis(Axis.CHILD);
        while(true) {
            NodeInfo curr = (NodeInfo)kids.next();
            if (curr == null) {
                break;
            }
            if (curr instanceof XSLWhen) {
                if (otherwise!=null) {
                    compileError("xsl:otherwise must come last");
                }
                numberOfWhens++;
            } else if (curr instanceof XSLOtherwise) {
                if (otherwise!=null) {
                    compileError("Only one xsl:otherwise allowed in an xsl:choose");
                } else {
                    otherwise = (StyleElement)curr;
                }
            } else if (curr.getNodeKind() == Type.TEXT &&
                        Navigator.isWhite(curr.getStringValue())) {
                compileError("Text node inside xsl:choose");
                // tolerate a whitespace text node; but it should have been stripped
                // by now.
            } else {
                compileError("Only xsl:when and xsl:otherwise are allowed here");
View Full Code Here

    */

    public void markTailCalls() {
        AxisIterator kids = iterateAxis(Axis.CHILD);
        while(true) {
            NodeInfo curr = (NodeInfo)kids.next();
            if (curr == null) {
                return;
            }
            if (curr instanceof StyleElement) {
                ((StyleElement)curr).markTailCalls();
View Full Code Here

        Expression[] actions = new Expression[entries];

        int w = 0;
        AxisIterator kids = iterateAxis(Axis.CHILD);
        while(true) {
            NodeInfo curr = (NodeInfo)kids.next();
            if (curr == null) {
                break;
            }
            if (curr instanceof XSLWhen) {
                conditions[w] = ((XSLWhen)curr).getCondition();
                Block b = new Block();
                b.setLocationId(allocateLocationId(getSystemId(), curr.getLineNumber()));
                ((XSLWhen)curr).compileChildren(exec, b, true);
                try {
                    actions[w] = b.simplify(((XSLWhen)curr).getStaticContext());
                } catch (XPathException e) {
                    compileError(e);
                }

                if (getConfiguration().getTraceListener() != null) {
                    TraceWrapper trace = makeTraceInstruction((XSLWhen)curr, actions[w]);
                    trace.setParentExpression(b);
                    actions[w] = trace;
                }

                // Optimize for constant conditions (true or false)
                if (conditions[w] instanceof BooleanValue) {
                    if (((BooleanValue)conditions[w]).getBooleanValue()) {
                        // constant true: truncate the tests here
                        entries = w+1;
                        break;
                    } else {
                        // constant false: omit this test
                        w--;
                        entries--;
                    }
                }
                w++;
            } else if (curr instanceof XSLOtherwise) {
                conditions[w] = BooleanValue.TRUE;
                Block b = new Block();
                b.setLocationId(allocateLocationId(getSystemId(), curr.getLineNumber()));
                ((XSLOtherwise)curr).compileChildren(exec, b, true);
                try {
                    actions[w] = b.simplify(((XSLOtherwise)curr).getStaticContext());
                } catch (XPathException e) {
                    compileError(e);
View Full Code Here

    public static NodeInfo build(Source source, Stripper stripper, Configuration config) throws XPathException {
        if (source == null) {
            throw new NullPointerException("Source supplied to builder cannot be null");
        }

        NodeInfo start;
        if (source instanceof DOMSource || source instanceof NodeInfo) {
            if (source instanceof DOMSource) {
                Node dsnode = ((DOMSource)source).getNode();
                if (dsnode instanceof NodeInfo) {
                    start = (NodeInfo)dsnode;
                } else {
                    Document dom;
                    if (dsnode instanceof Document) {
                        dom = (Document)dsnode;
                    } else {
                        dom = dsnode.getOwnerDocument();
                    }
                    DocumentWrapper docWrapper = new DocumentWrapper(dom, source.getSystemId(), config);
                    start = docWrapper.wrap(dsnode);
                }
            } else {
                start = (NodeInfo)source;
            }
            if (stripper != null) {
                DocumentInfo docInfo = start.getDocumentRoot();
                StrippedDocument strippedDoc = new StrippedDocument(docInfo, stripper);
                start = strippedDoc.wrap(start);
            }
            return start;
View Full Code Here

            if (it == null) {
                return false;
            }
            SequenceIterator nodes = km.selectByKey(keyfingerprint, doc, (AtomicValue)it, context);
            while (true) {
                NodeInfo n = (NodeInfo)nodes.next();
                if (n == null) {
                    break;
                }
                if (n.isSameNodeInfo(e)) {
                    return true;
                }
            }
        }
    }
View Full Code Here

        if (select != null) {
            // if there is a select attribute, check that there are no children other than xsl:sort and xsl:fallback
            AxisIterator kids = iterateAxis(Axis.CHILD);
            while (true) {
                NodeInfo child = (NodeInfo)kids.next();
                if (child == null) {
                    break;
                }
                if (child instanceof XSLSort || child instanceof XSLFallback) {
                    // no action
                } else if (child.getNodeKind() == Type.TEXT && !Navigator.isWhite(child.getStringValue())) {
                        // with xml:space=preserve, white space nodes may still be there
                        // ERR XT1040
                    compileError("Within xsl:perform-sort, significant text must not appear if there is a select attribute");
                } else {
                    // ERR XT1040
View Full Code Here

    public static SequenceIterator leading (
                     XPathContext context,
                     SequenceIterator ns1, SequenceIterator ns2) throws XPathException {

        NodeInfo first = null;

        // Find the first node in ns2 (in document order)

        GlobalOrderComparer comparer = GlobalOrderComparer.getInstance();
        while (true) {
            Item item = ns2.next();
            if (item == null) {
                if (first == null) {
                    return ns1;
                }
                break;
            }
            if (item instanceof NodeInfo) {
                NodeInfo node = (NodeInfo)item;
                if (first==null) {
                    first = node;
                } else {
                    if (comparer.compare(node, first) < 0) {
                        first = node;
View Full Code Here

        if (config.isStripsAllWhiteSpace()) {
            stripper = AllElementStripper.getInstance();
            stripper.setStripAll();
        }
        try {
            NodeInfo contextNode = Builder.build(source, stripper, config);
            return contextNode.getDocumentRoot();
        } catch (XPathException err) {
            Throwable cause = err.getException();
            if (cause != null && cause instanceof SAXParseException) {
                // This generally means the error was already reported.
                // But if a RuntimeException occurs in Saxon during a callback from
View Full Code Here

TOP

Related Classes of net.sf.saxon.om.NodeInfo

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.