use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class DefaultStaticContext method derives_from.
/**
* Checks if an XML node derives from a specified type.
*
* @param at
* node actual type
* @param et
* name of expected type
* @return true if a derivation exists
*/
// XXX fix this
public boolean derives_from(NodeType at, QName et) {
TypeDefinition td = _model.getType(at.node_value());
short method = TypeDefinition.DERIVATION_EXTENSION | TypeDefinition.DERIVATION_RESTRICTION;
// XXX
if (!et.expanded()) {
String pre = et.prefix();
if (pre != null) {
if (prefix_exists(pre)) {
et.set_namespace(resolve_prefix(pre));
} else
assert false;
} else
et.set_namespace(default_namespace());
}
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 SeqType method make_atomic.
private AnyAtomicType make_atomic(StaticContext sc, QName qname) {
String ns = qname.namespace();
Map functionLibraries = sc.getFunctionLibraries();
if (!functionLibraries.containsKey(ns))
return null;
FunctionLibrary fl = (FunctionLibrary) functionLibraries.get(ns);
if (!(fl instanceof ConstructorFL))
return null;
ConstructorFL cfl = (ConstructorFL) fl;
return cfl.atomic_type(qname);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class FnNodeName method node_name.
/**
* Node-Name operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:node-name operation.
*/
public static ResultSequence node_name(Collection args) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty())
return ResultBuffer.EMPTY;
NodeType nt = (NodeType) arg1.first();
QName nodename = nt.node_name();
if (nodename == null)
return ResultBuffer.EMPTY;
return nodename;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class PrefixFromQNameTest method test_fn_prefix_from_qname_18.
// Evaluates the "fn-prefix-from-qname" function as argument to ends-with function.
public void test_fn_prefix_from_qname_18() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/CompExpr/ValComp/QNameOp/PrefixFromQName/fn-prefix-from-qname-18.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/CompExpr/ValComp/QNameOp/PrefixFromQName/fn-prefix-from-qname-18.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
addNamespace("foo", "http://example.org");
String xpath = extractXPathExpression(xqFile, inputFile);
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 PrefixFromQNameTest method test_fn_prefix_from_qname_20.
// Evaluation of fn-prefix-fromQName function with two namespaces declared with same namespace (different case).
public void test_fn_prefix_from_qname_20() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/CompExpr/ValComp/QNameOp/PrefixFromQName/fn-prefix-from-qname-20.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/CompExpr/ValComp/QNameOp/PrefixFromQName/fn-prefix-from-qname-20.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
addNamespace("foo", "http://example.org");
String xpath = extractXPathExpression(xqFile, inputFile);
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);
}
Aggregations