use of org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType in project webtools.sourceediting by eclipse.
the class FnIDREF method processChildNodes.
private static ResultBuffer processChildNodes(Node node, List ids, ResultBuffer rs, EvaluationContext ec) {
if (!node.hasChildNodes()) {
return rs;
}
NodeList nodeList = node.getChildNodes();
for (int nodecnt = 0; nodecnt < nodeList.getLength(); nodecnt++) {
Node childNode = nodeList.item(nodecnt);
if (childNode.getNodeType() == Node.ELEMENT_NODE && !isDuplicate(childNode, rs)) {
ElementType element = new ElementType((Element) childNode, ec.getStaticContext().getTypeModel());
if (element.isIDREF()) {
if (hasID(ids, childNode)) {
rs.add(element);
}
}
rs = processAttributes(childNode, ids, rs, ec);
rs = processChildNodes(childNode, ids, rs, ec);
}
}
return rs;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType in project webtools.sourceediting by eclipse.
the class FnInScopePrefixes method inScopePrefixes.
/**
* Prefix-from-QName operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:prefix-from-QName operation.
*/
public static ResultSequence inScopePrefixes(Collection args, DynamicContext dc) throws DynamicError {
// Collection cargs = Function.convert_arguments(args, expected_args());
Collection cargs = args;
ResultSequence arg1 = (ResultSequence) cargs.iterator().next();
if (arg1.empty())
return ResultBuffer.EMPTY;
ResultBuffer rs = new ResultBuffer();
Item anytype = arg1.item(0);
if (!(anytype instanceof ElementType)) {
throw new DynamicError(TypeError.invalid_type(null));
}
ElementType element = (ElementType) anytype;
List prefixList = lookupPrefixes(element);
createPrefixResultSet(rs, prefixList);
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType in project webtools.sourceediting by eclipse.
the class FnID method processChildNodes.
private static void processChildNodes(Node node, List idrefs, ResultBuffer rs, EvaluationContext context) {
if (!node.hasChildNodes()) {
return;
}
NodeList nodeList = node.getChildNodes();
for (int nodecnt = 0; nodecnt < nodeList.getLength(); nodecnt++) {
Node childNode = nodeList.item(nodecnt);
if (childNode.getNodeType() == Node.ELEMENT_NODE && !isDuplicate(childNode, rs)) {
ElementType element = new ElementType((Element) childNode, context.getStaticContext().getTypeModel());
if (element.isID()) {
if (hasIDREF(idrefs, childNode)) {
rs.add(element);
}
}
processAttributes(childNode, idrefs, rs, context);
processChildNodes(childNode, idrefs, rs, context);
}
}
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType in project webtools.sourceediting by eclipse.
the class FnID method id.
/**
* Insert-Before operation.
*
* @param args
* Result from the expressions evaluation.
* @throws DynamicError
* Dynamic error.
* @return Result of fn:insert-before operation.
*/
public static ResultSequence id(Collection args, EvaluationContext context) throws DynamicError {
Collection cargs = Function.convert_arguments(args, expected_args());
ResultBuffer rs = new ResultBuffer();
Iterator argIt = cargs.iterator();
ResultSequence idrefRS = (ResultSequence) argIt.next();
String[] idrefst = idrefRS.first().getStringValue().split(" ");
ArrayList idrefs = createIDRefs(idrefst);
ResultSequence nodeArg = null;
NodeType nodeType = null;
if (argIt.hasNext()) {
nodeArg = (ResultSequence) argIt.next();
nodeType = (NodeType) nodeArg.first();
} else {
if (context.getContextItem() == null) {
throw DynamicError.contextUndefined();
}
if (!(context.getContextItem() instanceof NodeType)) {
throw new DynamicError(TypeError.invalid_type(null));
}
nodeType = (NodeType) context.getContextItem();
if (nodeType.node_value().getOwnerDocument() == null) {
throw DynamicError.contextUndefined();
}
}
Node node = nodeType.node_value();
if (node.getOwnerDocument() == null) {
// W3C Test suite seems to want XPDY0002
throw DynamicError.contextUndefined();
// throw DynamicError.noContextDoc();
}
if (hasIDREF(idrefs, node)) {
ElementType element = new ElementType((Element) node, context.getStaticContext().getTypeModel());
rs.add(element);
}
processAttributes(node, idrefs, rs, context);
processChildNodes(node, idrefs, rs, context);
return rs.getSequence();
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.ElementType in project webtools.sourceediting by eclipse.
the class ElementTest method createElementType.
private AnyType createElementType(Item at, StaticContext sc) {
anyType = new ElementType();
NodeType nodeType = (NodeType) at;
Node node = nodeType.node_value();
Document doc = null;
if (node.getNodeType() == Node.DOCUMENT_NODE) {
doc = (Document) node;
} else {
doc = nodeType.node_value().getOwnerDocument();
}
NodeList nodeList = null;
if (!wild()) {
nodeList = doc.getElementsByTagNameNS(name().namespace(), name().local());
} else {
nodeList = new SingleItemNodeListImpl(node);
}
if (nodeList.getLength() > 0) {
anyType = createElementForXSDType(nodeList, sc);
}
return anyType;
}
Aggregations