} // getXDMTypedValue /* * Get the XDM typed value for schema "simple content model". */ private ResultSequence getTypedValueForSimpleContent(SimpleTypeDefinition simpType, IList itemValueTypes) { ResultBuffer rs = new ResultBuffer(); if (simpType.Variety == org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition_Fields.VARIETY_ATOMIC) { AnyType schemaTypeValue = SchemaTypeValueFactory.newSchemaTypeValue(PsychoPathTypeHelper.getXSDTypeShortCode(simpType), StringValue); if (schemaTypeValue != null) { return(schemaTypeValue); } else { return(new XSUntypedAtomic(StringValue)); } } else if (simpType.Variety == org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition_Fields.VARIETY_LIST) { addAtomicListItemsToResultSet(simpType, itemValueTypes, rs); } else if (simpType.Variety == org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition_Fields.VARIETY_UNION) { getTypedValueForVarietyUnion(simpType, rs); } return(rs.Sequence); } // getTypedValueForSimpleContent
} // getTypedValueForSimpleContent /* * If the variety of simpleType was 'list', add the typed "list item" values to the parent result set. */ private void addAtomicListItemsToResultSet(SimpleTypeDefinition simpType, IList 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 = StringValue.Split("\\s+", true); SimpleTypeDefinition itemType = (SimpleTypeDefinition)simpType.ItemType; if (itemType.Variety == org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition_Fields.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.Variety == org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition_Fields.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[listItemIdx]).Value, listItem)); } } } // addAtomicListItemsToResultSet
protected internal virtual object getTypedValueForPrimitiveType(TypeDefinition typeDef) { string strValue = StringValue; if (typeDef == null) { return(new XSUntypedAtomic(strValue)); } return(SchemaTypeValueFactory.newSchemaTypeValue(PsychoPathTypeHelper.getXSDTypeShortCode(typeDef), strValue)); } // getTypedValueForPrimitiveType
} // addAtomicListItemsToResultSet /* * If the variety of simpleType was 'union', find the typed value (and added to the parent 'result set') * to be returned as the typed value of the parent node, by considering the member types of the union (i.e * whichever member type first in order, can successfully validate the string value of the parent node). */ private void getTypedValueForVarietyUnion(SimpleTypeDefinition simpType, ResultBuffer rs) { IList memberTypes = simpType.MemberTypes; // check member types in order, to find that which one can successfully validate the string value. for (int memTypeIdx = 0; memTypeIdx < memberTypes.Count; memTypeIdx++) { PrimitiveType memSimpleType = (PrimitiveType)memberTypes[memTypeIdx]; if (isValueValidForSimpleType(StringValue, memSimpleType)) { rs.add(SchemaTypeValueFactory.newSchemaTypeValue(PsychoPathTypeHelper.getXSDTypeShortCode(memSimpleType), StringValue)); // no more memberTypes need to be checked break; } } } // getTypedValueForVarietyUnion