use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class SeqType method match.
/**
* matches args
*
* @param args
* is a result sequence
* @throws a
* dynamic error
* @return a result sequence
*/
public ResultSequence match(ResultSequence args) throws DynamicError {
int occurrence = occurence();
// Check for empty sequence first
if (occurrence == OCC_EMPTY && !args.empty()) {
throw new DynamicError(TypeError.invalid_type(null));
}
int arg_count = 0;
for (Iterator i = args.iterator(); i.hasNext(); ) {
AnyType arg = (AnyType) i.next();
// make sure all args are the same type as expected type
if (!(typeClass.isInstance(arg))) {
throw new DynamicError(TypeError.invalid_type(null));
}
if (anytype != null) {
if ((nodeName != null || wild) && arg instanceof NodeType) {
NodeType nodeType = (NodeType) arg;
Node node = nodeType.node_value();
Node lnode = ((NodeType) anytype).node_value();
if (lnode == null) {
// throw new DynamicError(TypeError.invalid_type(null));
continue;
}
if (!lnode.isEqualNode(node)) {
// throw new DynamicError(TypeError.invalid_type(null));
continue;
}
}
}
arg_count++;
}
switch(occurrence) {
case OCC_NONE:
if (arg_count != 1) {
throw new DynamicError(TypeError.invalid_type(null));
}
break;
case OCC_PLUS:
if (arg_count == 0) {
throw new DynamicError(TypeError.invalid_type(null));
}
break;
case OCC_STAR:
break;
case OCC_QMARK:
if (arg_count > 1) {
throw new DynamicError(TypeError.invalid_type(null));
}
break;
default:
assert false;
}
return args;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType 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;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class AttributeTest method createAttrForXSDType.
private AnyType createAttrForXSDType(Node node, StaticContext sc) {
Attr attr = (Attr) node;
TypeModel typeModel = sc.getTypeModel();
TypeDefinition typedef = typeModel.getType(attr);
if (typedef != null) {
if (typedef.derivedFrom(type().namespace(), type().local(), getDerviationTypes())) {
anyType = new AttrType(attr, sc.getTypeModel());
}
} else {
anyType = new AttrType(attr, sc.getTypeModel());
}
return anyType;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class AttributeTest method createAttrType.
private AnyType createAttrType(Item at, StaticContext sc) {
anyType = new AttrType();
NodeType nodeType = (NodeType) at;
Node node = nodeType.node_value();
if (node == null) {
return anyType;
}
String nodeName = node.getLocalName();
if (wild()) {
if (type() != null) {
anyType = createAttrForXSDType(node, sc);
}
} else if (nodeName.equals(name().local())) {
if (type() != null) {
anyType = createAttrForXSDType(node, sc);
} else {
anyType = new AttrType((Attr) node, sc.getTypeModel());
}
}
return anyType;
}
use of org.eclipse.wst.xml.xpath2.processor.internal.types.AnyType in project webtools.sourceediting by eclipse.
the class XSDecimal method lt.
/**
* Comparison between this number and the supplied representation.
*
* @param arg
* Representation to be compared with (must currently be of type
* XSDecimal)
* @return True if the supplied type represents a number greater than this
* one stored. False otherwise
*/
public boolean lt(AnyType arg, DynamicContext context) throws DynamicError {
Item carg = convertArg(arg);
XSDecimal val = (XSDecimal) get_single_type(carg, XSDecimal.class);
return (_value.compareTo(val.getValue()) == -1);
}
Aggregations