Search in sources :

Example 46 with NodeType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.

the class ResultSequence method string.

/**
 * retrieve items in sequence
 *
 * @return result string
 */
public String string() {
    String result = "";
    int num = 1;
    StringBuffer buf = new StringBuffer();
    for (Iterator i = iterator(); i.hasNext(); ) {
        AnyType elem = (AnyType) i.next();
        buf.append(num + ") ");
        buf.append(elem.string_type() + ": ");
        String value = elem.getStringValue();
        if (elem instanceof NodeType) {
            QName tmp = ((NodeType) elem).node_name();
            if (tmp != null)
                value = tmp.expanded_name();
        }
        buf.append(value + "\n");
        num++;
    }
    result = buf.toString();
    if (num == 1)
        result = "Empty results\n";
    return result;
}
Also used : QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) AnyType(org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)

Example 47 with NodeType

use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.

the class OpIntersect method op_intersect.

/**
 * Op-Intersect operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of operation.
 */
public static ResultSequence op_intersect(Collection args) throws DynamicError {
    ResultBuffer rs = new ResultBuffer();
    // convert arguments
    Collection cargs = Function.convert_arguments(args, expected_args());
    // get arguments
    Iterator iter = cargs.iterator();
    ResultSequence one = (ResultSequence) iter.next();
    ResultSequence two = (ResultSequence) iter.next();
    // XXX lame
    for (Iterator i = one.iterator(); i.hasNext(); ) {
        NodeType node = (NodeType) i.next();
        boolean found = false;
        // death
        for (Iterator j = two.iterator(); j.hasNext(); ) {
            NodeType node2 = (NodeType) j.next();
            if (node.node_value() == node2.node_value()) {
                found = true;
                break;
            }
        }
        if (found)
            rs.add(node);
    }
    rs = NodeType.linarize(rs);
    return rs.getSequence();
}
Also used : ResultBuffer(org.eclipse.wst.xml.xpath2.api.ResultBuffer) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) Iterator(java.util.Iterator) Collection(java.util.Collection)

Aggregations

NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)39 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)23 Iterator (java.util.Iterator)21 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)15 Collection (java.util.Collection)12 Node (org.w3c.dom.Node)12 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)11 ListIterator (java.util.ListIterator)10 AnyType (org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType)9 ElementType (org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType)9 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)7 TypeDefinition (org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition)6 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)5 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)5 ArrayList (java.util.ArrayList)4 Attr (org.w3c.dom.Attr)4 ForwardAxis (org.eclipse.wst.xml.xpath2.processor.internal.ForwardAxis)3 ParentAxis (org.eclipse.wst.xml.xpath2.processor.internal.ParentAxis)3 ReverseAxis (org.eclipse.wst.xml.xpath2.processor.internal.ReverseAxis)3 AttrType (org.eclipse.wst.xml.xpath2.processor.internal.types.AttrType)3