use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NodeTestTest method test_NodeTest013_1.
// processing-instruction() gets descendant PIs of the given name.
public void test_NodeTest013_1() throws Exception {
String inputFile = "/TestSources/TreeCompass.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest013.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest013-1.xml";
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 = "fn:count($input-context//center/processing-instruction('a-pi'))";
String actual = null;
try {
compileXPath(xpath);
ResultSequence rs = evaluate(domDoc);
actual = "<out>" + buildResultString(rs) + "</out>";
} 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.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NameTestTest method test_nametest_3.
// Name test that uses an unknown prefix.
public void test_nametest_3() throws Exception {
String inputFile = "/TestSources/emptydoc.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/nametest-3.xq";
String expectedResult = "XPST0081";
URL fileURL = bundle.getEntry(inputFile);
loadDOMDocument(fileURL);
// Get XML Schema Information for the Document
XSModel schema = getGrammar();
setupDynamicContext(schema);
String xpath = extractXPathExpression(xqFile, inputFile);
xpath = "./child::pr:b";
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.ast.NodeTest in project webtools.sourceediting by eclipse.
the class StaticNameResolver method visit.
/**
* Validate a reverse step.
*
* @param e
* is the expression.
* @return null.
*/
public Object visit(ReverseStep e) {
NodeTest nt = e.node_test();
if (nt != null)
nt.accept(this);
ReverseAxis iterator = e.iterator();
if (iterator != null)
_axes.add(iterator.name());
return null;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NameTestTest method test_NodeTest005.
// Simple test for . and * node test.
public void test_NodeTest005() throws Exception {
String inputFile = "/TestSources/nw_Customers.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest005.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest005.xml";
String expectedResult = formatResultString(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 = buildXMLResultString(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.ast.NodeTest in project webtools.sourceediting by eclipse.
the class NameTestTest method test_NodeTest004.
// Simple test for . node test.
public void test_NodeTest004() throws Exception {
String inputFile = "/TestSources/nw_Customers.xml";
String xqFile = "/Queries/XQuery/Expressions/PathExpr/Steps/NodeTest/NodeTest004.xq";
String resultFile = "/ExpectedTestResults/Expressions/PathExpr/Steps/NodeTest/NodeTest004.xml";
String expectedResult = formatResultString(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 = buildXMLResultString(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