use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class FnPrefixFromQName method prefix.
/**
* Prefix-from-QName operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:prefix-from-QName operation.
*/
public static ResultSequence prefix(Collection args, StaticContext sc) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
// get arg
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty())
return ResultBuffer.EMPTY;
QName qname = (QName) arg1.first();
String prefix = qname.prefix();
if (prefix != null) {
if (!XMLConstants.NULL_NS_URI.equals(sc.getNamespaceContext().getNamespaceURI(prefix))) {
return new XSNCName(prefix);
} else {
throw DynamicError.invalidPrefix();
}
}
return ResultBuffer.EMPTY;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class FnPrefixFromQName 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 QName(), SeqType.OCC_QMARK);
_expected_args.add(arg);
}
return _expected_args;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.QName in project webtools.sourceediting by eclipse.
the class QNameEQTest method test_op_qname_equal_4.
// Evaluates the "op:qname-equal" operator used with simple different qname values (different namespace URI values, same local part). Uses the ne operator.
public void test_op_qname_equal_4() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/CompExpr/ValComp/QNameOp/QNameEQ/op-qname-equal-4.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/CompExpr/ValComp/QNameOp/QNameEQ/op-qName-equal-4.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
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 QNameEQTest method test_op_qname_equal_18.
// Evaluates the "op:qname-equal" operator used with second namespace URI set to empty string, same local part and no prefix. Uses the ne operator.
public void test_op_qname_equal_18() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/CompExpr/ValComp/QNameOp/QNameEQ/op-qname-equal-18.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/CompExpr/ValComp/QNameOp/QNameEQ/op-qname-equal-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);
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 QNameEQTest method test_op_qname_equal_21.
// Evaluates the "op:qname-equal" operator used as an argument to the fn:not function. Uses the eq operator.
public void test_op_qname_equal_21() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/CompExpr/ValComp/QNameOp/QNameEQ/op-qname-equal-21.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/CompExpr/ValComp/QNameOp/QNameEQ/op-qname-equal-21.txt";
String expectedResult = getExpectedResult(resultFile);
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
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