use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.
the class FnCollection method getCollection.
private static ResultSequence getCollection(String uri, EvaluationContext ec) {
ResultBuffer rs = new ResultBuffer();
Map /*<String, List<Document>>*/
collectionMap = ec.getDynamicContext().getCollections();
List /*<Document>*/
docList = (List) collectionMap.get(uri);
for (int i = 0; i < docList.size(); i++) {
Document doc = (Document) docList.get(i);
rs.add(new DocType(doc, ec.getStaticContext().getTypeModel()));
}
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.
the class DefaultDynamicContext method get_doc.
/**
* get document
*
* @return a ResultSequence from ResultSequenceFactory.create_new()
* @since 1.1
*/
public ResultSequence get_doc(URI resolved) {
Document doc = null;
if (_loaded_documents.containsKey(resolved)) {
// tried before
doc = (Document) _loaded_documents.get(resolved);
} else {
doc = retrieve_doc(resolved);
_loaded_documents.put(resolved, doc);
}
if (doc == null)
return null;
return ResultSequenceFactory.create_new(new DocType(doc, getTypeModel(doc)));
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.
the class AbstractPsychoPathWTPTest method setupVariables.
protected DynamicContext setupVariables(DynamicContext dc) {
dc.add_variable(new QName("x"));
dc.add_variable(new QName("var"));
if (domDoc != null) {
AnyType docType = new DocType(domDoc, dc.getTypeModel(domDoc));
dc.set_variable(new QName("input-context1"), docType);
dc.set_variable(new QName("input-context"), docType);
if (domDoc2 == null) {
dc.set_variable(new QName("input-context2"), docType);
} else {
dc.set_variable(new QName("input-context2"), (AnyType) new DocType(domDoc2, dc.getTypeModel(domDoc2)));
}
}
return dc;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit document test.
*
* @param e
* is the document test.
* @return result sequence
*/
public Object visit(DocumentTest e) {
ResultSequence arg = (ResultSequence) ((Pair) _param)._two;
int type = e.type();
// filter doc nodes
ResultSequence rs = kind_test(arg, DocType.class);
if (type == DocumentTest.NONE)
return rs;
// the element test
for (Iterator i = rs.iterator(); i.hasNext(); ) {
DocType doc = (DocType) i.next();
int elem_count = 0;
ElementType elem = null;
// make sure doc has only 1 element
NodeList children = doc.node_value().getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
// bingo
if (child.getNodeType() == Node.ELEMENT_NODE) {
elem_count++;
if (elem_count > 1)
break;
elem = new ElementType((Element) child, _sc.getTypeModel());
}
}
// this doc is no good... send him to hell
if (elem_count != 1) {
i.remove();
continue;
}
assert elem != null;
// setup parameter for element test
ResultSequence res = new ResultBuffer.SingleResultSequence(elem);
_param = new Pair("element", res);
// do name test
res = null;
if (type == DocumentTest.ELEMENT)
res = (ResultSequence) e.elem_test().accept(this);
else if (type == DocumentTest.SCHEMA_ELEMENT)
res = (ResultSequence) e.schema_elem_test().accept(this);
else
assert false;
// check if element survived nametest
if (res.size() != 1)
i.remove();
}
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.DocType in project webtools.sourceediting by eclipse.
the class ChildAxis method addChildren.
protected void addChildren(NodeType node, ResultBuffer copyInto, boolean recurse) {
NodeList nl = null;
// only document and element nodes have children
if (node instanceof DocType) {
nl = ((DocType) node).value().getChildNodes();
}
if (node instanceof ElementType)
nl = ((ElementType) node).value().getChildNodes();
// add the children to the result
if (nl != null) {
for (int i = 0; i < nl.getLength(); i++) {
Node dnode = nl.item(i);
NodeType n = NodeType.dom_to_xpath(dnode, node.getTypeModel());
if (n != null) {
copyInto.add(n);
if (recurse)
addChildren(n, copyInto, recurse);
}
}
}
}
Aggregations