Package net.sf.saxon.om

Examples of net.sf.saxon.om.NodeInfo


    /**
    * Evaluate the expression
    */

    public Item evaluateItem(XPathContext context) throws XPathException {
        NodeInfo node1 = getNode(operand0, context);
        if (node1==null) {
            if (generateIdEmulation) {
                return BooleanValue.get(getNode(operand1, context)==null);
            }
            return null;
        }

        NodeInfo node2 = getNode(operand1, context);
        if (node2==null) {
            if (generateIdEmulation) {
                return BooleanValue.FALSE;
            }
            return null;
View Full Code Here


        return BooleanValue.get(compareIdentity(node1, node2));
    }

    public boolean effectiveBooleanValue(XPathContext context) throws XPathException {
        NodeInfo node1 = getNode(operand0, context);
        if (node1==null) {
            return generateIdEmulation && getNode(operand1, context) == null;
        }

        NodeInfo node2 = getNode(operand1, context);
        return node2 != null && compareIdentity(node1, node2);

    }
View Full Code Here

        options.setLineNumbering(lineNumbering);
        if (source.getSystemId() == null && baseURI != null) {
            source.setSystemId(baseURI.toString());
        }
        try {
            NodeInfo doc = config.buildDocument(source, options);
            return new XdmNode(doc);
        } catch (XPathException e) {
            throw new SaxonApiException(e);
        }
    }                                                          
View Full Code Here

     * object model is not on the class path
     */

    public XdmNode wrap(Object node) throws IllegalArgumentException {
         if (node instanceof NodeInfo) {
             NodeInfo nodeInfo = (NodeInfo)node;
             if (nodeInfo.getConfiguration().isCompatible(config)) {
                return new XdmNode((NodeInfo)node);
             } else {
                 throw new IllegalArgumentException("Supplied NodeInfo was created using a different Configuration");
             }
         } else {
             try {
                 JPConverter converter = JPConverter.allocate(node.getClass(), config);
                 NodeInfo nodeInfo = (NodeInfo)converter.convert(node, new EarlyEvaluationContext(config, null));
                 return (XdmNode)XdmItem.wrapItem(nodeInfo);
             } catch (XPathException e) {
                 throw new IllegalArgumentException(e.getMessage());
             }
         }
View Full Code Here

        try {
            if (expression.isUpdateQuery()) {
                Set docs = expression.runUpdate(context);
                updatedDocuments = new HashSet();
                for (Iterator iter = docs.iterator(); iter.hasNext();) {
                    NodeInfo root = (NodeInfo)iter.next();
                    updatedDocuments.add((XdmNode)XdmNode.wrapItem(root));
                }
            } else {
                if (destination == null) {
                    throw new IllegalStateException("No destination supplied");
View Full Code Here

    /**
    * Evaluate the function at run-time
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo node = (NodeInfo)argument[0].evaluateItem(c);
        if (node==null) {
            return null;
        }
        String s = node.getBaseURI();
        if (s == null) {
            return null;
        }
        return new AnyURIValue(s);
    }
View Full Code Here

        );

        // Run the first query
        final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
        dynamicContext.setParameter("in", new Long(3));
        final NodeInfo doc = (NodeInfo)exp1.evaluateSingle(dynamicContext);

        // Run the second query
        dynamicContext.clearParameters();
        dynamicContext.setContextNode(doc);
        final Object result = exp2.evaluateSingle(dynamicContext);
View Full Code Here

                            new TransformerException("Validation request ignored for a NodeInfo source"));
                } catch (TransformerException e) {
                    throw XPathException.wrap(e);
                }
            }
            NodeInfo ns = (NodeInfo)source;
            int kind = ns.getNodeKind();
            if (kind != Type.DOCUMENT && kind != Type.ELEMENT) {
                throw new IllegalArgumentException("Sender can only handle document or element nodes");
            }
            sendDocumentInfo(ns, receiver, config.getNamePool());
View Full Code Here

        // Now return an iterator over the documents that it refers to

        SequenceIterator iter =
                catalog.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT);
        NodeInfo top = null;
        while (true) {
            top = (NodeInfo)iter.next();
            if (top == null) break;
            if (!("collection".equals(top.getLocalPart()) &&
                    top.getURI().equals("") )) {
                dynamicError("collection catalogue must contain top-level element <collection>", context);
            }
            break;
        }

        SequenceIterator documents =
                top.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT);

        return new MappingIterator(documents, this, context, null);

    }
View Full Code Here

     * @throws XPathException if the document cannot be retrieved or parsed, unless
     * error recovery has been chosen.
     */

    public Object map(Item item, XPathContext context, Object info) throws XPathException {
        NodeInfo element = (NodeInfo)item;
        if (!("doc".equals(element.getLocalPart()) &&
                element.getURI().equals("") )) {
            dynamicError("children of <collection> element must be <doc> elements", context);
        }
        String href = Navigator.getAttributeValue(element, "", "href");
        if (href==null) {
            dynamicError("<doc> element in catalogue has no @href attribute", context);
        }

        NodeInfo target = Document.makeDoc(href, element.getBaseURI(), context);
        return target;
    }
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.