use of org.eclipse.wst.xml.xpath2.api.typesystem.ItemType in project webtools.sourceediting by eclipse.
the class TestBugs method testNulVarNamespacePrefix.
public void testNulVarNamespacePrefix() throws Exception {
// Bug 345326
String xpath = "for $a in //* return $a";
new Engine().parseExpression(xpath, new StaticContext() {
public boolean isXPath1Compatible() {
return false;
}
public StaticVariableResolver getInScopeVariables() {
return null;
}
public TypeDefinition getInitialContextType() {
return null;
}
public Map getFunctionLibraries() {
return null;
}
public CollationProvider getCollationProvider() {
return null;
}
public URI getBaseUri() {
return null;
}
public ItemType getDocumentType(URI documentUri) {
return null;
}
public NamespaceContext getNamespaceContext() {
return new NamespaceContext() {
public String getNamespaceURI(String arg0) {
if (arg0 == null)
throw new IllegalArgumentException("#fail");
return XMLConstants.NULL_NS_URI;
}
public String getPrefix(String arg0) {
if (arg0 == null)
throw new IllegalArgumentException("#fail");
return XMLConstants.DEFAULT_NS_PREFIX;
}
public Iterator getPrefixes(String arg0) {
if (arg0 == null)
throw new IllegalArgumentException("#fail");
return Collections.emptyList().iterator();
}
};
}
public String getDefaultNamespace() {
return XMLConstants.NULL_NS_URI;
}
public String getDefaultFunctionNamespace() {
return null;
}
public TypeModel getTypeModel() {
return null;
}
public Function resolveFunction(QName name, int arity) {
return null;
}
public TypeDefinition getCollectionType(String collectionName) {
return null;
}
public TypeDefinition getDefaultCollectionType() {
return null;
}
});
}
use of org.eclipse.wst.xml.xpath2.api.typesystem.ItemType in project webtools.sourceediting by eclipse.
the class DefaultEvaluator method visit.
/**
* visit item type.
*
* @param e
* is the item type.
* @return null
*/
public Object visit(ItemType e) {
switch(e.type()) {
case ItemType.ITEM:
break;
case ItemType.QNAME:
boolean ok = false;
TypeModel model = _sc.getTypeModel();
if (model != null) {
ok = _sc.getTypeModel().lookupType(e.qname().namespace(), e.qname().local()) != null;
}
if (!ok) {
ok = BuiltinTypeLibrary.BUILTIN_TYPES.lookupType(e.qname().namespace(), e.qname().local()) != null;
}
if (!ok)
report_error(new StaticTypeNameError("Type not defined: " + e.qname().string()));
ResultSequence arg = (ResultSequence) ((Pair) _param)._two;
((Pair) _param)._two = item_test(arg, e.qname());
break;
case ItemType.KINDTEST:
((Pair) _param)._two = e.kind_test().accept(this);
break;
}
return null;
}
use of org.eclipse.wst.xml.xpath2.api.typesystem.ItemType in project webtools.sourceediting by eclipse.
the class NodeType method addAtomicListItemsToResultSet.
// getTypedValueForSimpleContent
/*
* If the variety of simpleType was 'list', add the typed "list item" values to the parent result set.
*/
private void addAtomicListItemsToResultSet(SimpleTypeDefinition simpType, List itemValueTypes, ResultBuffer rs) {
// tokenize the string value by a 'longest sequence' of white-spaces. this gives us the list items as string values.
String[] listItemsStrValues = getStringValue().split("\\s+");
SimpleTypeDefinition itemType = (SimpleTypeDefinition) simpType.getItemType();
if (itemType.getVariety() == SimpleTypeDefinition.VARIETY_ATOMIC) {
for (int listItemIdx = 0; listItemIdx < listItemsStrValues.length; listItemIdx++) {
// add an atomic typed value (whose type is the "item type" of the list, and "string value" is the "string
// value of the list item") to the "result sequence".
rs.add(SchemaTypeValueFactory.newSchemaTypeValue(PsychoPathTypeHelper.getXSDTypeShortCode(itemType), listItemsStrValues[listItemIdx]));
}
} else if (itemType.getVariety() == SimpleTypeDefinition.VARIETY_UNION) {
// here the list items may have different atomic types
for (int listItemIdx = 0; listItemIdx < listItemsStrValues.length; listItemIdx++) {
String listItem = listItemsStrValues[listItemIdx];
rs.add(SchemaTypeValueFactory.newSchemaTypeValue(((Short) itemValueTypes.get(listItemIdx)).shortValue(), listItem));
}
}
}
Aggregations