use of org.eclipse.wst.xml.xpath2.api.StaticContext 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.api.StaticContext in project webtools.sourceediting by eclipse.
the class Engine method parseExpression.
public XPath2Expression parseExpression(String expression, StaticContext context) {
XPath xPath = new JFlexCupParser().parse(expression);
xPath.setStaticContext(context);
StaticNameResolver name_check = new StaticNameResolver(context);
name_check.check(xPath);
xPath.setAxes(name_check.getAxes());
xPath.setFreeVariables(name_check.getFreeVariables());
xPath.setResolvedFunctions(name_check.getResolvedFunctions());
xPath.setRootUsed(name_check.isRootUsed());
return xPath;
}
use of org.eclipse.wst.xml.xpath2.api.StaticContext 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