use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnIDREF method processAttributes.
private static ResultBuffer processAttributes(Node node, List idrefs, ResultBuffer rs, EvaluationContext ec) {
if (!node.hasAttributes()) {
return rs;
}
NamedNodeMap attributeList = node.getAttributes();
for (int atsub = 0; atsub < attributeList.getLength(); atsub++) {
Attr atNode = (Attr) attributeList.item(atsub);
NodeType atType = new AttrType(atNode, ec.getStaticContext().getTypeModel());
if (atType.isID()) {
if (hasID(idrefs, atNode)) {
if (!isDuplicate(node, rs)) {
ElementType element = new ElementType((Element) node, ec.getStaticContext().getTypeModel());
rs.add(element);
}
}
}
}
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnNamespaceUri method namespace_uri.
/**
* Namespace-Uri operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:namespace-uri operation.
*/
public static ResultSequence namespace_uri(Collection args, EvaluationContext context) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultSequence arg1 = null;
if (cargs.isEmpty()) {
if (context.getContextItem() == null) {
throw DynamicError.contextUndefined();
}
arg1 = (AnyType) context.getContextItem();
} else {
// get arg
arg1 = (ResultSequence) cargs.iterator().next();
}
if (arg1.empty()) {
return new XSAnyURI("");
}
NodeType an = (NodeType) arg1.first();
QName name = an.node_name();
String sname = "";
if (name != null)
sname = name.namespace();
return new XSAnyURI(sname);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class commaOpTest method test_op_concatenate_mix_args_019.
// Use an external variable with op:concatenate.
public void test_op_concatenate_mix_args_019() throws Exception {
String inputFile = "/TestSources/bib.xml";
String xqFile = "/Queries/XQuery/Expressions/Operators/SeqOp/SeqConcat/op-concatenate-mix-args-019.xq";
String resultFile = "/ExpectedTestResults/Expressions/Operators/SeqOp/SeqConcat/op-concatenate-mix-args-019.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 = buildXMLResultString(rs);
// Iterator<NodeType> iterator = rs.iterator();
// while (iterator.hasNext()) {
// AnyType aat = iterator.next();
// if (!(aat instanceof NodeType)) {
// actual += aat.string_value();
// }
// }
} 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.NodeType in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method buildXMLResultString.
protected String buildXMLResultString(ResultSequence rs) throws Exception {
Iterator iterator = rs.iterator();
StringBuffer buffer = new StringBuffer();
while (iterator.hasNext()) {
AnyType aat = (AnyType) iterator.next();
if (aat instanceof NodeType) {
NodeType nodeType = (NodeType) aat;
IDOMNode node = (IDOMNode) nodeType.node_value();
buffer = buffer.append(node.getSource());
} else {
buffer = buffer.append(aat.string_value());
}
}
return buffer.toString();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FnID method processAttributes.
private static void processAttributes(Node node, List idrefs, ResultBuffer rs, EvaluationContext context) {
if (!node.hasAttributes()) {
return;
}
NamedNodeMap attributeList = node.getAttributes();
for (int atsub = 0; atsub < attributeList.getLength(); atsub++) {
Attr atNode = (Attr) attributeList.item(atsub);
NodeType atType = new AttrType(atNode, context.getStaticContext().getTypeModel());
if (atType.isID()) {
if (hasIDREF(idrefs, atNode)) {
if (!isDuplicate(node, rs)) {
ElementType element = new ElementType((Element) node, context.getStaticContext().getTypeModel());
rs.add(element);
}
}
}
}
}
Aggregations