Beispiel #1
0
        }         // 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
Beispiel #2
0
        }         // 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
Beispiel #3
0
        }         // getTypedValueForPrimitiveType

        /*
         * Construct the "typed value" from a "string value", given the simpleType of the node.
         */
        protected internal virtual ResultSequence getXDMTypedValue(TypeDefinition typeDef, IList itemValTypes)
        {
            if ("anySimpleType".Equals(typeDef.Name) || "anyAtomicType".Equals(typeDef.Name))
            {
                return(new XSUntypedAtomic(StringValue));
            }
            else
            {
                SimpleTypeDefinition simpType = null;

                if (typeDef is ComplexTypeDefinition)
                {
                    ComplexTypeDefinition complexTypeDefinition = (ComplexTypeDefinition)typeDef;
                    simpType = complexTypeDefinition.SimpleType;
                    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(StringValue));
                    }
                }
                else
                {
                    // element has a simpleType
                    simpType = (SimpleTypeDefinition)typeDef;
                    return(getTypedValueForSimpleContent(simpType, itemValTypes));
                }
            }
        }         // getXDMTypedValue
Beispiel #4
0
        }         // 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