use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit a reverse step expression
*
* @param e
* is the reverse step.
* @return a new function
*/
// XXX unify with top
public Object visit(ReverseStep e) {
// get context node
AnyType ci = focus().context_item();
if (!(ci instanceof NodeType))
report_error(TypeError.ci_not_node(ci.string_type()));
NodeType cn = (NodeType) ci;
// get the nodes on the axis
ReverseAxis axis = e.iterator();
ResultBuffer result = new ResultBuffer();
// short for "gimme da parent"
if (e.axis() == ReverseStep.DOTDOT) {
new ParentAxis().iterate(cn, result, _dc.getLimitNode());
return result.getSequence();
}
assert axis != null;
axis.iterate(cn, result, null);
// get all nodes in the axis, and principal node
Pair arg = new Pair(axis.principal_node_kind().string_type(), result.getSequence());
// do the name test
_param = arg;
ResultSequence rs = (ResultSequence) e.node_test().accept(this);
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit attribute test.
*
* @param e
* is the attribute test.
* @return a result sequence
*/
public Object visit(AttributeTest e) {
// filter out all attrs
ResultSequence rs = kind_test((ResultSequence) ((Pair) _param)._two, AttrType.class);
ResultBuffer rb = new ResultBuffer();
QName name = e.name();
QName type = e.type();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
NodeType node = (NodeType) i.next();
// match the name if it's not a wild card
if (name != null && !e.wild()) {
if (!name_test(node, name, "attribute"))
continue;
}
// match the type
if (type != null) {
// check if element derives from
if (!derivesFrom(node, type))
continue;
}
rb.add(node);
}
((Pair) _param)._two = rb.getSequence();
return ((Pair) _param)._two;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit a forward step expression
*
* @param e
* is the forward step.
* @return a new function
*/
public Object visit(ForwardStep e) {
// get context node
AnyType ci = focus().context_item();
if (ci == null)
report_error(DynamicError.contextUndefined());
if (!(ci instanceof NodeType))
report_error(TypeError.ci_not_node(ci.string_type()));
NodeType cn = (NodeType) ci;
// get the nodes on the axis
ForwardAxis axis = e.iterator();
ResultBuffer rb = new ResultBuffer();
axis.iterate(cn, rb, _dc.getLimitNode());
// get all nodes in the axis, and principal node
Pair arg = new Pair(axis.principal_node_kind().string_type(), rb.getSequence());
// do the name test
_param = arg;
ResultSequence rs = (ResultSequence) e.node_test().accept(this);
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit schema element test.
*
* @param e
* is the schema element test.
* @return a result sequence
*/
public Object visit(SchemaElemTest e) {
// filter out all elements
ResultSequence rs = kind_test((ResultSequence) ((Pair) _param)._two, ElementType.class);
// match the name
// XXX substitution groups
QName name = e.name();
for (Iterator i = rs.iterator(); i.hasNext(); ) {
if (!name_test((ElementType) i.next(), name, "element"))
i.remove();
}
// check the type
TypeDefinition et = _sc.getTypeModel().lookupElementDeclaration(name.namespace(), name.local());
for (Iterator i = rs.iterator(); i.hasNext(); ) {
NodeType node = (NodeType) i.next();
if (!derivesFrom(node, et)) {
i.remove();
continue;
}
XSBoolean nilled = (XSBoolean) node.nilled().first();
// XXX or, in schema it is nillable
if (nilled.value())
i.remove();
}
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method root_self_node.
private ResultSequence root_self_node() {
Axis axis = new SelfAxis();
ResultBuffer buffer = new ResultBuffer();
// XXX the cast!!!
axis.iterate((NodeType) focus().context_item(), buffer, _dc.getLimitNode());
ResultSequence rs = kind_test(buffer.getSequence(), NodeType.class);
List records = new ArrayList();
records.add(rs);
rs = FnRoot.fn_root(records, _ec);
return rs;
}
Aggregations