Search in sources :

Example 1 with SimpleTypeDefinition

use of org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition 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));
        }
    }
}
Also used : SimpleTypeDefinition(org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition)

Example 2 with SimpleTypeDefinition

use of org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition 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);
        }
    }
}
Also used : ComplexTypeDefinition(org.eclipse.wst.xml.xpath2.api.typesystem.ComplexTypeDefinition) SimpleTypeDefinition(org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition)

Aggregations

SimpleTypeDefinition (org.eclipse.wst.xml.xpath2.api.typesystem.SimpleTypeDefinition)2 ComplexTypeDefinition (org.eclipse.wst.xml.xpath2.api.typesystem.ComplexTypeDefinition)1