Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTMAxisIterator#next()

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTMAxisIterator#next() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoadDocument.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private static DTMAxisIterator document(DTMAxisIterator arg1,
                                        String baseURI,
                                        AbstractTranslet translet, DOM dom)
throws Exception
{
    UnionIterator union = new UnionIterator(dom);
    int node = DTM.NULL;

    while ((node = arg1.next()) != DTM.NULL) {
        String uri = dom.getStringValueX(node);
        //document(node-set) if true;  document(node-set,node-set) if false
        if (baseURI  == null) {
           baseURI = dom.getDocumentURI(node);
           if (!SystemIDResolver.isAbsoluteURI(baseURI))
                baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
        }
        union.addIterator(document(uri, baseURI, translet, dom));
    }
    return(union);
}
 
Example 2
Source File: LoadDocument.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private static DTMAxisIterator document(DTMAxisIterator arg1,
                                        String baseURI,
                                        AbstractTranslet translet, DOM dom)
throws Exception
{
    UnionIterator union = new UnionIterator(dom);
    int node = DTM.NULL;

    while ((node = arg1.next()) != DTM.NULL) {
        String uri = dom.getStringValueX(node);
        //document(node-set) if true;  document(node-set,node-set) if false
        if (baseURI  == null) {
           baseURI = dom.getDocumentURI(node);
           if (!SystemIDResolver.isAbsoluteURI(baseURI))
                baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
        }
        union.addIterator(document(uri, baseURI, translet, dom));
    }
    return(union);
}
 
Example 3
Source File: BasisLibrary.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/string comparison.
 */
public static boolean compare(DTMAxisIterator left, final String rstring,
                              int op, DOM dom) {
    int node;
    //left.reset();
    while ((node = left.next()) != DTMAxisIterator.END) {
        if (compareStrings(dom.getStringValueX(node), rstring, op, dom)) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: BasisLibrary.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/string comparison.
 */
public static boolean compare(DTMAxisIterator left, final String rstring,
                              int op, DOM dom) {
    int node;
    //left.reset();
    while ((node = left.next()) != DTMAxisIterator.END) {
        if (compareStrings(dom.getStringValueX(node), rstring, op, dom)) {
            return true;
        }
    }
    return false;
}
 
Example 5
Source File: BasisLibrary.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * XSLT Standard function sum(node-set).
 * stringToDouble is inlined
 */
public static double sumF(DTMAxisIterator iterator, DOM dom) {
    try {
        double result = 0.0;
        int node;
        while ((node = iterator.next()) != DTMAxisIterator.END) {
            result += Double.parseDouble(dom.getStringValueX(node));
        }
        return result;
    }
    catch (NumberFormatException e) {
        return Double.NaN;
    }
}
 
Example 6
Source File: LoadDocument.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 2 arguments arg1 and arg2.  document(Obj, node-set) call
 */
public static DTMAxisIterator documentF(Object arg1, DTMAxisIterator arg2,
                        String xslURI, AbstractTranslet translet, DOM dom)
throws TransletException {
    String baseURI = null;
    final int arg2FirstNode = arg2.next();
    if (arg2FirstNode == DTMAxisIterator.END) {
        //  the second argument node-set is empty
        return EmptyIterator.getInstance();
    } else {
        //System.err.println("arg2FirstNode name: "
        //                   + dom.getNodeName(arg2FirstNode )+"["
        //                   +Integer.toHexString(arg2FirstNode )+"]");
        baseURI = dom.getDocumentURI(arg2FirstNode);
        if (!SystemIDResolver.isAbsoluteURI(baseURI))
           baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
    }

    try {
        if (arg1 instanceof String) {
            if (((String)arg1).length() == 0) {
                return document(xslURI, "", translet, dom);
            } else {
                return document((String)arg1, baseURI, translet, dom);
            }
        } else if (arg1 instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg1, baseURI, translet, dom);
        } else {
            final String err = "document("+arg1.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example 7
Source File: LoadDocument.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 2 arguments arg1 and arg2.  document(Obj, node-set) call
 */
public static DTMAxisIterator documentF(Object arg1, DTMAxisIterator arg2,
                        String xslURI, AbstractTranslet translet, DOM dom)
throws TransletException {
    String baseURI = null;
    final int arg2FirstNode = arg2.next();
    if (arg2FirstNode == DTMAxisIterator.END) {
        //  the second argument node-set is empty
        return EmptyIterator.getInstance();
    } else {
        //System.err.println("arg2FirstNode name: "
        //                   + dom.getNodeName(arg2FirstNode )+"["
        //                   +Integer.toHexString(arg2FirstNode )+"]");
        baseURI = dom.getDocumentURI(arg2FirstNode);
        if (!SystemIDResolver.isAbsoluteURI(baseURI))
           baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
    }

    try {
        if (arg1 instanceof String) {
            if (((String)arg1).length() == 0) {
                return document(xslURI, "", translet, dom);
            } else {
                return document((String)arg1, baseURI, translet, dom);
            }
        } else if (arg1 instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg1, baseURI, translet, dom);
        } else {
            final String err = "document("+arg1.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example 8
Source File: LoadDocument.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 2 arguments arg1 and arg2.  document(Obj, node-set) call
 */
public static DTMAxisIterator documentF(Object arg1, DTMAxisIterator arg2,
                        String xslURI, AbstractTranslet translet, DOM dom)
throws TransletException {
    String baseURI = null;
    final int arg2FirstNode = arg2.next();
    if (arg2FirstNode == DTMAxisIterator.END) {
        //  the second argument node-set is empty
        return EmptyIterator.getInstance();
    } else {
        //System.err.println("arg2FirstNode name: "
        //                   + dom.getNodeName(arg2FirstNode )+"["
        //                   +Integer.toHexString(arg2FirstNode )+"]");
        baseURI = dom.getDocumentURI(arg2FirstNode);
        if (!SystemIDResolver.isAbsoluteURI(baseURI))
           baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
    }

    try {
        if (arg1 instanceof String) {
            if (((String)arg1).length() == 0) {
                return document(xslURI, "", translet, dom);
            } else {
                return document((String)arg1, baseURI, translet, dom);
            }
        } else if (arg1 instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg1, baseURI, translet, dom);
        } else {
            final String err = "document("+arg1.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example 9
Source File: MultiDOM.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
        throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL) {
        _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].copy(node, handler);
    }
}
 
Example 10
Source File: BasisLibrary.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Utility function: node-set/string comparison.
 */
public static boolean compare(DTMAxisIterator left, final String rstring,
                              int op, DOM dom) {
    int node;
    //left.reset();
    while ((node = left.next()) != DTMAxisIterator.END) {
        if (compareStrings(dom.getStringValueX(node), rstring, op, dom)) {
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: SimpleResultTreeImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL)
    {
        copy(node, handler);
    }
}
 
Example 12
Source File: BasisLibrary.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility function: node-set/node-set compare.
 */
public static boolean compare(DTMAxisIterator left, DTMAxisIterator right,
                              int op, DOM dom) {
    int lnode;
    left.reset();

    while ((lnode = left.next()) != DTMAxisIterator.END) {
        final String lvalue = dom.getStringValueX(lnode);

        int rnode;
        right.reset();
        while ((rnode = right.next()) != DTMAxisIterator.END) {
            // String value must be the same if both nodes are the same
            if (lnode == rnode) {
                if (op == Operators.EQ) {
                    return true;
                } else if (op == Operators.NE) {
                    continue;
                }
            }
            if (compareStrings(lvalue, dom.getStringValueX(rnode), op,
                               dom)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 13
Source File: BasisLibrary.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Utility function: node-set/string comparison.
 */
public static boolean compare(DTMAxisIterator left, final String rstring,
                              int op, DOM dom) {
    int node;
    //left.reset();
    while ((node = left.next()) != DTMAxisIterator.END) {
        if (compareStrings(dom.getStringValueX(node), rstring, op, dom)) {
            return true;
        }
    }
    return false;
}
 
Example 14
Source File: LoadDocument.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Interprets the arguments passed from the document() function (see
 * com/sun/org/apache/xalan/internal/xsltc/compiler/DocumentCall.java) and returns an
 * iterator containing the requested nodes. Builds a union-iterator if
 * several documents are requested.
 * 2 arguments arg1 and arg2.  document(Obj, node-set) call
 */
public static DTMAxisIterator documentF(Object arg1, DTMAxisIterator arg2,
                        String xslURI, AbstractTranslet translet, DOM dom)
throws TransletException {
    String baseURI = null;
    final int arg2FirstNode = arg2.next();
    if (arg2FirstNode == DTMAxisIterator.END) {
        //  the second argument node-set is empty
        return EmptyIterator.getInstance();
    } else {
        //System.err.println("arg2FirstNode name: "
        //                   + dom.getNodeName(arg2FirstNode )+"["
        //                   +Integer.toHexString(arg2FirstNode )+"]");
        baseURI = dom.getDocumentURI(arg2FirstNode);
        if (!SystemIDResolver.isAbsoluteURI(baseURI))
           baseURI = SystemIDResolver.getAbsoluteURIFromRelative(baseURI);
    }

    try {
        if (arg1 instanceof String) {
            if (((String)arg1).length() == 0) {
                return document(xslURI, "", translet, dom);
            } else {
                return document((String)arg1, baseURI, translet, dom);
            }
        } else if (arg1 instanceof DTMAxisIterator) {
            return document((DTMAxisIterator)arg1, baseURI, translet, dom);
        } else {
            final String err = "document("+arg1.toString()+")";
            throw new IllegalArgumentException(err);
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example 15
Source File: SAXImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy a node-set to an output handler
 */
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL) {
        copy(node, handler);
    }
}
 
Example 16
Source File: BasisLibrary.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * XSLT Standard function sum(node-set).
 * stringToDouble is inlined
 */
public static double sumF(DTMAxisIterator iterator, DOM dom) {
    try {
        double result = 0.0;
        int node;
        while ((node = iterator.next()) != DTMAxisIterator.END) {
            result += Double.parseDouble(dom.getStringValueX(node));
        }
        return result;
    }
    catch (NumberFormatException e) {
        return Double.NaN;
    }
}
 
Example 17
Source File: KeyIndex.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Evaluate the reference to the <code>key</code> or <code>id</code>
 * function with the context specified by {@link #setStartNode(int)}
 * and set up this iterator to iterate over the DTM nodes that are
 * to be returned.
 */
protected void init() {
    super.init();
    _position = 0;

    // All nodes retrieved are in the same document
    int rootHandle = _dom.getAxisIterator(Axis.ROOT)
                              .setStartNode(_startNode).next();

    // Is the argument not a node set?
    if (_keyValueIterator == null) {
        // Look up nodes returned for the single string argument
        _nodes = lookupNodes(rootHandle, _keyValue);

        if (_nodes == null) {
            _nodes = EMPTY_NODES;
        }
    } else {
        DTMAxisIterator keyValues = _keyValueIterator.reset();
        int retrievedKeyValueIdx = 0;
        boolean foundNodes = false;

        _nodes = null;

        // For each node in the node set argument, get the string value
        // and look up the nodes returned by key or id for that string
        // value.  If at most one string value has nodes associated,
        // the nodes will be stored in _nodes; otherwise, the nodes
        // will be placed in a heap.
        for (int keyValueNode = keyValues.next();
             keyValueNode != DTMAxisIterator.END;
             keyValueNode = keyValues.next()) {

            String keyValue = BasisLibrary.stringF(keyValueNode, _dom);

            IntegerArray nodes = lookupNodes(rootHandle, keyValue);

            if (nodes != null) {
                if (!foundNodes) {
                    _nodes = nodes;
                    foundNodes = true;
                } else {
                    if (_nodes != null) {
                        addHeapNode(new KeyIndexHeapNode(_nodes));
                        _nodes = null;
                    }
                    addHeapNode(new KeyIndexHeapNode(nodes));
                }
            }
        }

        if (!foundNodes) {
            _nodes = EMPTY_NODES;
        }
    }
}
 
Example 18
Source File: BasisLibrary.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Utility function: used with nth position filters to convert a sequence
 * of nodes to just one single node (the one at position n).
 */
public static DTMAxisIterator getSingleNode(DTMAxisIterator iterator) {
    int node = iterator.next();
    return(new SingletonIterator(node));
}
 
Example 19
Source File: BasisLibrary.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static boolean compare(int node, DTMAxisIterator iterator,
                              int op, DOM dom) {
    //iterator.reset();

    int rnode;
    String value;

    switch(op) {
case Operators.EQ:
        rnode = iterator.next();
        if (rnode != DTMAxisIterator.END) {
            value = dom.getStringValueX(node);
            do {
                if (node == rnode
                      || value.equals(dom.getStringValueX(rnode))) {
                   return true;
                }
            } while ((rnode = iterator.next()) != DTMAxisIterator.END);
        }
        break;
case Operators.NE:
        rnode = iterator.next();
        if (rnode != DTMAxisIterator.END) {
            value = dom.getStringValueX(node);
            do {
                if (node != rnode
                      && !value.equals(dom.getStringValueX(rnode))) {
                    return true;
                }
            } while ((rnode = iterator.next()) != DTMAxisIterator.END);
        }
        break;
case Operators.LT:
        // Assume we're comparing document order here
        while ((rnode = iterator.next()) != DTMAxisIterator.END) {
            if (rnode > node) return true;
        }
        break;
case Operators.GT:
        // Assume we're comparing document order here
        while ((rnode = iterator.next()) != DTMAxisIterator.END) {
            if (rnode < node) return true;
        }
        break;
    }
    return(false);
}
 
Example 20
Source File: BasisLibrary.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static boolean compare(int node, DTMAxisIterator iterator,
                              int op, DOM dom) {
    //iterator.reset();

    int rnode;
    String value;

    switch(op) {
case Operators.EQ:
        rnode = iterator.next();
        if (rnode != DTMAxisIterator.END) {
            value = dom.getStringValueX(node);
            do {
                if (node == rnode
                      || value.equals(dom.getStringValueX(rnode))) {
                   return true;
                }
            } while ((rnode = iterator.next()) != DTMAxisIterator.END);
        }
        break;
case Operators.NE:
        rnode = iterator.next();
        if (rnode != DTMAxisIterator.END) {
            value = dom.getStringValueX(node);
            do {
                if (node != rnode
                      && !value.equals(dom.getStringValueX(rnode))) {
                    return true;
                }
            } while ((rnode = iterator.next()) != DTMAxisIterator.END);
        }
        break;
case Operators.LT:
        // Assume we're comparing document order here
        while ((rnode = iterator.next()) != DTMAxisIterator.END) {
            if (rnode > node) return true;
        }
        break;
case Operators.GT:
        // Assume we're comparing document order here
        while ((rnode = iterator.next()) != DTMAxisIterator.END) {
            if (rnode < node) return true;
        }
        break;
    }
    return(false);
}