use of org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method derivesFrom.
private boolean derivesFrom(NodeType at, QName et) {
TypeDefinition td = _sc.getTypeModel().getType(at.node_value());
short method = TypeDefinition.DERIVATION_EXTENSION | TypeDefinition.DERIVATION_RESTRICTION;
return td != null && td.derivedFrom(et.namespace(), et.local(), method);
}
use of org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition 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.api.typesystem.TypeDefinition 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.api.typesystem.TypeDefinition in project webtools.sourceediting by eclipse.
the class ElementTest method createElementForXSDType.
private AnyType createElementForXSDType(NodeList nodeList, StaticContext sc) {
for (int i = 0; i < nodeList.getLength(); i++) {
Element element = (Element) nodeList.item(i);
TypeModel typeModel = sc.getTypeModel();
TypeDefinition typedef = typeModel.getType(element);
if (type() == null || typedef == null) {
anyType = new ElementType(element, typeModel);
break;
} else {
if (typedef.derivedFrom(type().namespace(), type().local(), getDerviationTypes())) {
anyType = new ElementType(element, typeModel);
break;
}
}
}
return anyType;
}
use of org.eclipse.wst.xml.xpath2.api.typesystem.TypeDefinition in project webtools.sourceediting by eclipse.
the class NodeType method getXDMTypedValue.
// getTypedValueForPrimitiveType
/*
* Construct the "typed value" from a "string value", given the simpleType of the node.
*/
protected ResultSequence getXDMTypedValue(TypeDefinition typeDef, List itemValTypes) {
if ("anySimpleType".equals(typeDef.getName()) || "anyAtomicType".equals(typeDef.getName())) {
return new XSUntypedAtomic(getStringValue());
} else {
SimpleTypeDefinition simpType = null;
if (typeDef instanceof ComplexTypeDefinition) {
ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition) typeDef;
simpType = complexTypeDefinition.getSimpleType();
if (simpType != null) {
// element has a complexType with a simple content
return getTypedValueForSimpleContent(simpType, itemValTypes);
} else {
// element has a complexType with complex content
return new XSUntypedAtomic(getStringValue());
}
} else {
// element has a simpleType
simpType = (SimpleTypeDefinition) typeDef;
return getTypedValueForSimpleContent(simpType, itemValTypes);
}
}
}
Aggregations