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;
}
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;
}
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;
}
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);
}
}
}
}
}
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;
}
Aggregations