Package client.net.sf.saxon.ce.om

Examples of client.net.sf.saxon.ce.om.NodeInfo


    /**
    * Evaluate the function in a string context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo node = (NodeInfo)argument[0].evaluateItem(c);
        if (node==null) {
            // Effect of supplying an empty sequence as the argument differs depending on the function
            if (operation == NODE_NAME || operation == DOCUMENT_URI ) {
                return null;
            } else if (operation == NAMESPACE_URI) {
                return AnyURIValue.EMPTY_URI;
            } else {
                return StringValue.EMPTY_STRING;
            }
        }

        String s;
        switch (operation) {
            case NAME:
                s = node.getDisplayName();
                break;
            case LOCAL_NAME:
                s = node.getLocalPart();
                break;
            case NAMESPACE_URI:
                String uri = node.getURI();
                s = (uri==null ? "" : uri);
                        // null should no longer be returned, but the spec has changed, so it's
                        // better to be defensive
                return new AnyURIValue(s);

            case GENERATE_ID:
                FastStringBuffer buffer = new FastStringBuffer(FastStringBuffer.TINY);
                node.generateId(buffer);
                buffer.condense();
                return new StringValue(buffer);

            case DOCUMENT_URI:
                // If the node is in the document pool, get the URI under which it is registered.
                // Otherwise, return its systemId.
                return getDocumentURI(node, c);
            case NODE_NAME:
                int nc = node.getNameCode();
                if (nc == -1) {
                    return null;
                }
                return new QNameValue(node.getNamePool(), nc);
            default:
                throw new UnsupportedOperationException("Unknown name operation");
        }
        return new StringValue(s);
    }
View Full Code Here


    /**
    * Iterator over the results of the expression
    */

    public SequenceIterator iterate(final XPathContext context) throws XPathException {
        final NodeInfo element = (NodeInfo)argument[0].evaluateItem(context);
        final Iterator<NamespaceBinding> iter = NamespaceIterator.iterateNamespaces(element);
        final List<String> prefixes = new ArrayList<String>();
        prefixes.add("xml");
        while (iter.hasNext()) {
            prefixes.add(iter.next().getPrefix());
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo start = (NodeInfo)argument[0].evaluateItem(c);
        if (start==null) {
            return null;
        }
        return start.getRoot();
    }
View Full Code Here

    /**
    * Evaluate in a general context
    */

    public Item evaluateItem(XPathContext c) throws XPathException {
        NodeInfo target;
        if (argument.length > 1) {
            target = (NodeInfo)argument[1].evaluateItem(c);
        } else {
            Item current = c.getContextItem();
            if (current==null) {
View Full Code Here

    * @param target the target node
    */

    public static boolean isLang(String arglang, NodeInfo target) {
        String doclang = null;
        NodeInfo node = target;

        while(node!=null) {
            doclang = Navigator.getAttributeValue(node, NamespaceConstant.XML, "lang");
            if (doclang!=null) {
                break;
            }
            node = node.getParent();
            if (node==null) {
                return false;
            }
        }

View Full Code Here

    * Evaluate the function to return an iteration of selected nodes.
    */

    public SequenceIterator iterate(XPathContext context) throws XPathException {

        NodeInfo arg1;
        try {
            arg1 = (NodeInfo)argument[1].evaluateItem(context);
        } catch (XPathException e) {
            if (context.getContextItem() instanceof AtomicValue) {
                // Override the unhelpful message that trickles down..
                dynamicError("For the " + getFunctionName().getLocalName() +
                        "() function, the context item is not a node", "XPTY0004", context);
                return null;
            } else {
                throw e;
            }
        }
        arg1 = arg1.getRoot();
        if (arg1.getNodeKind() != Type.DOCUMENT) {
            dynamicError("In the " + getFunctionName().getLocalName() + "() function," +
                            " the tree being searched must be one whose root is a document node", "FODC0001", context);
            return null;
        }
        DocumentInfo doc = (DocumentInfo)arg1;
View Full Code Here

     * if the prefix is not in scope
     * @throws XPathException if a failure occurs evaluating the arguments
     */

    public Item evaluateItem(XPathContext context) throws XPathException {
        NodeInfo element = (NodeInfo)argument[1].evaluateItem(context);
        StringValue p = (StringValue)argument[0].evaluateItem(context);
        String prefix;
        if (p == null) {
            prefix = "";
        } else {
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

            seq.endElement();
            seq.close();

            // the constructed element is the first and only item in the sequence
            NodeInfo result = (NodeInfo)seq.popLastItem();
            seq.reset();
            return result;

        } catch (XPathException err) {
            err.maybeSetLocation(getSourceLocator());
View Full Code Here

     /**
    * Evaluate the expression
    */

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

        NodeInfo node2 = getNode(operand1, context);
        if (node2==null) {
            return null;
        }

        return BooleanValue.get(compareIdentity(node1, node2));
View Full Code Here

TOP

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