use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class AncestorAxis method iterate.
/**
* Get the ancestors of the context node.
*
* @param node
* is the type of node.
*/
// XXX unify this with descendants axis ?
public void iterate(NodeType node, ResultBuffer copyInto, Node limitNode) {
if (limitNode != null && limitNode.isSameNode(node.node_value()))
return;
int before = copyInto.size();
// get the parent
super.iterate(node, copyInto, limitNode);
// no parent
if (copyInto.size() == before)
return;
NodeType parent = (NodeType) copyInto.item(before);
// get ancestors of parent
iterate(parent, copyInto, limitNode);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class AttributeAxis method iterate.
/**
* Retrieves the context node's attributes.
*
* @param node
* is the type of node.
*/
public void iterate(NodeType node, ResultBuffer copyInto, Node limitNode) {
// only elements have attributes
if (!(node instanceof ElementType))
return;
// get attributes
ElementType elem = (ElementType) node;
NamedNodeMap attrs = elem.value().getAttributes();
// add attributes
for (int i = 0; i < attrs.getLength(); i++) {
Attr attr = (Attr) attrs.item(i);
copyInto.add(NodeType.dom_to_xpath(attr, node.getTypeModel()));
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType 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);
}
}
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class DefaultStaticContext method derives_from.
/**
* Checks if an XML node derives from a specified type definition.
*
* @param at
* node actual type.
* @param et
* type definition of expected type.
* @return true if a derivation exists.
*/
public boolean derives_from(NodeType at, TypeDefinition et) {
TypeDefinition td = _model.getType(at.node_value());
short method = 0;
return td.derivedFromType(et, method);
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.NodeType in project webtools.sourceediting by eclipse.
the class FollowingAxis method iterate.
/**
* Return the result of FollowingAxis expression
*
* @param node
* is the type of node.
*/
public void iterate(NodeType node, ResultBuffer result, Node limitNode) {
if (limitNode != null && limitNode.isSameNode(node.node_value())) {
// no further, we have reached the limit node
return;
}
// get the parent
NodeType parent = null;
ResultBuffer parentBuffer = new ResultBuffer();
new ParentAxis().iterate(node, parentBuffer, limitNode);
if (parentBuffer.size() == 1)
parent = (NodeType) parentBuffer.item(0);
// get the following siblings of this node, and add them
FollowingSiblingAxis fsa = new FollowingSiblingAxis();
ResultBuffer siblingBuffer = new ResultBuffer();
fsa.iterate(node, siblingBuffer, limitNode);
// for each sibling, get all its descendants
DescendantAxis da = new DescendantAxis();
for (Iterator i = siblingBuffer.iterator(); i.hasNext(); ) {
result.add((NodeType) i);
da.iterate((NodeType) i.next(), result, null);
}
// and add the results
if (parent != null) {
iterate(parent, result, limitNode);
}
}
Aggregations