Search in sources :

Example 16 with ElementType

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

the class FnIDREF method processAttributes.

private static ResultBuffer processAttributes(Node node, List idrefs, ResultBuffer rs, EvaluationContext ec) {
    if (!node.hasAttributes()) {
        return rs;
    }
    NamedNodeMap attributeList = node.getAttributes();
    for (int atsub = 0; atsub < attributeList.getLength(); atsub++) {
        Attr atNode = (Attr) attributeList.item(atsub);
        NodeType atType = new AttrType(atNode, ec.getStaticContext().getTypeModel());
        if (atType.isID()) {
            if (hasID(idrefs, atNode)) {
                if (!isDuplicate(node, rs)) {
                    ElementType element = new ElementType((Element) node, ec.getStaticContext().getTypeModel());
                    rs.add(element);
                }
            }
        }
    }
    return rs;
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) NamedNodeMap(org.w3c.dom.NamedNodeMap) AttrType(org.eclipse.wst.xml.xpath2.processor.internal.types.AttrType) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) Attr(org.w3c.dom.Attr)

Example 17 with ElementType

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

the class FnResolveQName method expected_args.

/**
 * Obtain a list of expected arguments.
 *
 * @return Result of operation.
 */
public static synchronized Collection expected_args() {
    if (_expected_args == null) {
        _expected_args = new ArrayList();
        SeqType arg = new SeqType(new XSString(), SeqType.OCC_QMARK);
        _expected_args.add(arg);
        _expected_args.add(new SeqType(new ElementType(), SeqType.OCC_NONE));
    }
    return _expected_args;
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) SeqType(org.eclipse.wst.xml.xpath2.processor.internal.SeqType) ArrayList(java.util.ArrayList) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 18 with ElementType

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

the class FnResolveQName method resolve_QName.

/**
 * Resolve-QName operation.
 *
 * @param args
 *            Result from the expressions evaluation.
 * @param sc
 *            Result of static context operation.
 * @throws DynamicError
 *             Dynamic error.
 * @return Result of fn:resolve-QName operation.
 */
public static ResultSequence resolve_QName(Collection args, StaticContext sc) throws DynamicError {
    // Collection cargs = Function.convert_arguments(args, expected_args());
    Collection cargs = args;
    // get args
    Iterator argiter = cargs.iterator();
    ResultSequence arg1 = (ResultSequence) argiter.next();
    if (arg1.empty())
        return ResultBuffer.EMPTY;
    ResultSequence arg2 = (ResultSequence) argiter.next();
    String name = ((XSString) arg1.first()).value();
    QName qn = QName.parse_QName(name);
    if (qn == null)
        throw DynamicError.lexical_error(null);
    ElementType xselement = (ElementType) arg2.first();
    Element element = (Element) xselement.node_value();
    if (qn.prefix() != null) {
        String namespaceURI = element.lookupNamespaceURI(qn.prefix());
        if (namespaceURI == null) {
            throw DynamicError.invalidPrefix();
        }
        qn.set_namespace(namespaceURI);
    } else {
        if (qn.local().equals(element.getLocalName()) && element.isDefaultNamespace(element.getNamespaceURI())) {
            qn.set_namespace(element.getNamespaceURI());
        }
    }
    return qn;
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) ResultSequence(org.eclipse.wst.xml.xpath2.api.ResultSequence) QName(org.eclipse.wst.xml.xpath2.processor.internal.types.QName) Element(org.w3c.dom.Element) Iterator(java.util.Iterator) Collection(java.util.Collection) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString) XSString(org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)

Example 19 with ElementType

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

the class FnID method processAttributes.

private static void processAttributes(Node node, List idrefs, ResultBuffer rs, EvaluationContext context) {
    if (!node.hasAttributes()) {
        return;
    }
    NamedNodeMap attributeList = node.getAttributes();
    for (int atsub = 0; atsub < attributeList.getLength(); atsub++) {
        Attr atNode = (Attr) attributeList.item(atsub);
        NodeType atType = new AttrType(atNode, context.getStaticContext().getTypeModel());
        if (atType.isID()) {
            if (hasIDREF(idrefs, atNode)) {
                if (!isDuplicate(node, rs)) {
                    ElementType element = new ElementType((Element) node, context.getStaticContext().getTypeModel());
                    rs.add(element);
                }
            }
        }
    }
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) NamedNodeMap(org.w3c.dom.NamedNodeMap) AttrType(org.eclipse.wst.xml.xpath2.processor.internal.types.AttrType) NodeType(org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType) Attr(org.w3c.dom.Attr)

Example 20 with ElementType

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

the class ElementTest method createElementForXSDType.

private AnyType createElementForXSDType(NodeList nodeList, StaticContext sc) {
    for (int i = 0; i < nodeList.getLength(); i++) {
        Element element = (Element) nodeList.item(i);
        TypeModel typeModel = sc.getTypeModel();
        TypeDefinition typedef = typeModel.getType(element);
        if (type() == null || typedef == null) {
            anyType = new ElementType(element, typeModel);
            break;
        } else {
            if (typedef.derivedFrom(type().namespace(), type().local(), getDerviationTypes())) {
                anyType = new ElementType(element, typeModel);
                break;
            }
        }
    }
    return anyType;
}
Also used : ElementType(org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType) Element(org.w3c.dom.Element) TypeModel(org.eclipse.wst.xml.xpath2.api.typesystem.TypeModel) TypeDefinition(org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition)

Aggregations

ElementType (org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType)19 NodeType (org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType)8 Node (org.w3c.dom.Node)8 ResultSequence (org.eclipse.wst.xml.xpath2.api.ResultSequence)7 ArrayList (java.util.ArrayList)6 Iterator (java.util.Iterator)6 XSString (org.eclipse.wst.xml.xpath2.processor.internal.types.XSString)5 NodeList (org.w3c.dom.NodeList)5 Collection (java.util.Collection)4 ResultBuffer (org.eclipse.wst.xml.xpath2.api.ResultBuffer)4 Element (org.w3c.dom.Element)4 NamedNodeMap (org.w3c.dom.NamedNodeMap)4 ListIterator (java.util.ListIterator)3 DynamicError (org.eclipse.wst.xml.xpath2.processor.DynamicError)3 VarExprPair (org.eclipse.wst.xml.xpath2.processor.internal.ast.VarExprPair)3 QName (org.eclipse.wst.xml.xpath2.processor.internal.types.QName)3 Attr (org.w3c.dom.Attr)3 List (java.util.List)2 XSModel (org.apache.xerces.xs.XSModel)2 TypeDefinition (org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition)2