use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class ResolveQNameFuncTest method test_fn_resolve_qname_1.
public void test_fn_resolve_qname_1() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Functions/URIFunc/ResolveURIFunc/fn-resolve-uri-1.xq";
String expectedResult = "FOCA0002";
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = "fn:resolve-QName(\"aName::\", /doc)";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = buildResultString(rs);
} catch (XPathParserException ex) {
actual = ex.code();
} catch (StaticError ex) {
actual = ex.code();
} catch (DynamicError ex) {
actual = ex.code();
}
assertEquals("XPath Result Error " + xqFile + ":", expectedResult, actual);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_for_each.
private void do_for_each(ListIterator iter, Expr finalexpr, ResultBuffer destination) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
// XXX
if (rs.empty()) {
iter.previous();
return;
}
QName varname = ve.varname();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
do_for_each(iter, finalexpr, destination);
popScope();
}
iter.previous();
} else // we finally got to do the "last expression"
{
destination.concat((ResultSequence) finalexpr.accept(this));
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method derivesFrom.
private boolean derivesFrom(NodeType at, QName et) {
TypeDefinition td = _sc.getTypeModel().getType(at.node_value());
short method = TypeDefinition.DERIVATION_EXTENSION | TypeDefinition.DERIVATION_RESTRICTION;
return td != null && td.derivedFrom(et.namespace(), et.local(), method);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit attribute test.
*
* @param e
* is the attribute test.
* @return a result sequence
*/
public Object visit(AttributeTest e) {
// filter out all attrs
ResultSequence rs = kind_test((ResultSequence) ((Pair) _param)._two, AttrType.class);
ResultBuffer rb = new ResultBuffer();
QName name = e.name();
QName type = e.type();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
NodeType node = (NodeType) i.next();
// match the name if it's not a wild card
if (name != null && !e.wild()) {
if (!name_test(node, name, "attribute"))
continue;
}
// match the type
if (type != null) {
// check if element derives from
if (!derivesFrom(node, type))
continue;
}
rb.add(node);
}
((Pair) _param)._two = rb.getSequence();
return ((Pair) _param)._two;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method do_for_all.
// XXX ugly
// type: 0 = for [return == "correct"]
// 1 = for all [return false, return empty on true]
// 2 = there exists [return true, return empty on false]
private XSBoolean do_for_all(ListIterator iter, Expr finalexpr) {
// we have more vars to bind...
if (iter.hasNext()) {
VarExprPair ve = (VarExprPair) iter.next();
// evaluate binding sequence
ResultSequence rs = (ResultSequence) ve.expr().accept(this);
QName varname = ve.varname();
try {
for (Iterator i = rs.iterator(); i.hasNext(); ) {
AnyType item = (AnyType) i.next();
pushScope(varname, item);
XSBoolean effbool = do_for_all(iter, finalexpr);
popScope();
// out what to do with it
if (!effbool.value())
return XSBoolean.FALSE;
}
} finally {
iter.previous();
}
return XSBoolean.TRUE;
} else // we finally got to do the "last expression"
{
return effective_boolean_value((ResultSequence) finalexpr.accept(this));
}
}
Aggregations