Examples of XmlSchemaSimpleTypeRestriction


Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

                                                       boolean anonymous)
        throws Exception {
        CorbaTypeImpl corbaTypeImpl = null;
   
        // checks if enumeration
        XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction)stype
            .getContent();
       
        QName baseName = checkPrefix(restrictionType.getBaseTypeName());
       
        String maxLength = null;
        String length = null;

        Iterator i = restrictionType.getFacets().getIterator();
        while (i.hasNext()) {
            XmlSchemaFacet val = (XmlSchemaFacet)i.next();
            if (val instanceof XmlSchemaMaxLengthFacet) {               
                maxLength = val.getValue().toString();
            }
            if (val instanceof XmlSchemaLengthFacet) {
                length = val.getValue().toString();
            }
        }
       
        if (isEnumeration(restrictionType)) {
            corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
        } else {
            if (restrictionType.getBaseType() != null) {
                corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName,
                                                         stype, false);
            } else {               
                corbaTypeImpl = processPrimitiveType(baseName);               
                if (corbaTypeImpl == null) {
                    XmlSchemaType schematype = findSchemaType(baseName);
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

        }
       
        // xmlschema:simpleType
        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(schema);
        simpleType.setName(typeNameNode.toString());
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
        restriction.setBaseTypeName(type.getQName());
        simpleType.setContent(restriction);
       
        // add xmlschema:simpleType
        getSchema().getItems().add(simpleType);
        getSchema().addType(simpleType);
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

        if (parentSimpleTypeQname == null) {
            parentSimpleTypeQname = (QName) simpleType.getMetaInfoMap().get(SchemaConstants.SchemaCompilerInfoHolder.FAKE_QNAME);
        }
        if (content != null) {
            if (content instanceof XmlSchemaSimpleTypeRestriction) {
                XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;

                QName baseTypeName = restriction.getBaseTypeName();
                //check whether the base type is one of the base schema types

                if (baseSchemaTypeMap.containsKey(baseTypeName)) {
                    //process restriction base type

                    processSimpleRestrictionBaseType(parentSimpleTypeQname, restriction.getBaseTypeName(), metaInfHolder, parentSchema);
                    //process facets
                    if (!SchemaConstants.XSD_BOOLEAN.equals(baseTypeName)){
                        processFacets(restriction, metaInfHolder, parentSchema);
                    }
                } else {
                    //recurse
                    // this must be a xmlschema bug
                    // it should return the schematype for restriction.getBaseType():
                    XmlSchema resolvedSchema = getParentSchema(parentSchema, baseTypeName, COMPONENT_TYPE);
                    if (resolvedSchema == null) {
                        throw new SchemaCompilationException("can not find the type " + baseTypeName +
                                " from the parent schema " + parentSchema.getTargetNamespace());
                    } else {
                        XmlSchemaType restrictionBaseType = resolvedSchema.getTypeByName(baseTypeName);
                        if (restrictionBaseType instanceof XmlSchemaSimpleType) {
                            if ((restrictionBaseType != null) && (!isAlreadyProcessed(baseTypeName))) {
                                processSimpleSchemaType((XmlSchemaSimpleType) restrictionBaseType,
                                        null, resolvedSchema, null);
                            }
                            // process restriction
                            processSimpleRestrictionBaseType(parentSimpleTypeQname,
                                    restriction.getBaseTypeName(), metaInfHolder, resolvedSchema);
                        }
                    }

                }
            } else if (content instanceof XmlSchemaSimpleTypeUnion) {
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

                                                       boolean anonymous)
        throws Exception {
        CorbaTypeImpl corbaTypeImpl = null;

        // checks if enumeration
        XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction)stype
            .getContent();

        QName baseName = checkPrefix(restrictionType.getBaseTypeName());

        String maxLength = null;
        String length = null;

        for (XmlSchemaFacet val : restrictionType.getFacets()) {
            if (val instanceof XmlSchemaMaxLengthFacet) {
                maxLength = val.getValue().toString();
            }
            if (val instanceof XmlSchemaLengthFacet) {
                length = val.getValue().toString();
            }
        }

        if (isEnumeration(restrictionType)) {
            corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
        } else {
            if (restrictionType.getBaseType() != null) {
                corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName,
                                                         stype, null, false);
            } else {
                corbaTypeImpl = processPrimitiveType(baseName);
                if (corbaTypeImpl == null) {
                    XmlSchemaType schematype = findSchemaType(baseName);
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

    public static boolean isEumeration(XmlSchemaSimpleType type) {
        XmlSchemaSimpleTypeContent content = type.getContent();
        if (!(content instanceof XmlSchemaSimpleTypeRestriction)) {
            return false;
        }
        XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
        List<XmlSchemaFacet> facets = restriction.getFacets();
        for (XmlSchemaFacet facet : facets) {
            if (!(facet instanceof XmlSchemaEnumerationFacet)) {
                return false;
            }
        }
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

     * @param type
     * @return
     */
    public static List<String> enumeratorValues(XmlSchemaSimpleType type) {
        XmlSchemaSimpleTypeContent content = type.getContent();
        XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
        List<XmlSchemaFacet> facets = restriction.getFacets();
        List<String> values = new ArrayList<String>();
        for (XmlSchemaFacet facet : facets) {
            XmlSchemaEnumerationFacet enumFacet = (XmlSchemaEnumerationFacet) facet;
            values.add(enumFacet.getValue().toString());
        }
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

                    Object type = baseSchemaTypeMap.get(attrTypeName);
                    if (type == null) {
                      XmlSchemaSimpleType simpleType = attribute.getSchemaType();
                            if(simpleType != null && simpleType.getContent() instanceof XmlSchemaSimpleTypeRestriction) {
                                XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) simpleType.getContent();
                                QName baseTypeName = restriction.getBaseTypeName();
                                type = baseSchemaTypeMap.get(baseTypeName);
                                attrQname = att.getRefName();
                            }
                            //TODO: Handle XmlSchemaSimpleTypeUnion and XmlSchemaSimpleTypeList
                        }
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

        // handle the restriction
        XmlSchemaSimpleTypeContent content = simpleType.getContent();
        if (content != null) {
            if (content instanceof XmlSchemaSimpleTypeRestriction) {
                XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
               
                QName baseTypeName = restriction.getBaseTypeName();
                //check whether the base type is one of the base schema types
                if (baseSchemaTypeMap.containsKey(baseTypeName)) {
                    //process restriction base type
                    QName qName = simpleType.getQName();
                    if(qName == null) {
                        qName = (QName) simpleType.getMetaInfoMap().get(SchemaConstants.SchemaCompilerInfoHolder.FAKE_QNAME);
                    }
                    processSimpleRestrictionBaseType(qName, restriction.getBaseTypeName(),metaInfHolder);
         
                    //process facets
                    XmlSchemaObjectCollection facets = restriction.getFacets();
                    processFacets(facets,metaInfHolder);
                } else {
                    //recurse
                    if (restriction.getBaseType() != null) {
                        processSimpleSchemaType(restriction.getBaseType(), null, parentSchema);
                    }
                }
            }else if (content instanceof XmlSchemaSimpleTypeUnion) {
                //Todo - Handle unions here
                throw new SchemaCompilationException(
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

     * @param name  - The name of the parameter
     * @param enums - Array of enumeration values
     * @return XmlSchemaSimpleType - An XmlSchemaSimpleType which has a restriction and the enumaration.
     */
    private XmlSchemaSimpleType handleEnumeration(String name, String[] enums) {
        XmlSchemaSimpleTypeRestriction simpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
        // Set the base type to string. 95% of the time enumerations are strings so use it.
        simpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
        XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema);
        simpleType.setName(name);
        simpleType.setContent(simpleTypeRestriction);

        // Create enumeration facets for each value
        for (int i = 0; i < enums.length; i++) {

            String enumeration = enums[i].trim();
            XmlSchemaEnumerationFacet enumerationFacet = new XmlSchemaEnumerationFacet();
            enumerationFacet.setValue(enumeration);
            simpleTypeRestriction.getFacets().add(enumerationFacet);
        }

        return simpleType;
    }
View Full Code Here

Examples of org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction

                typeInfo.simpleBaseType = list.getItemType().getQName();

                // this is a list
                typeInfo.listType = true;
            } else if (content instanceof XmlSchemaSimpleTypeRestriction) {
                final XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) content;
                typeInfo.simpleBaseType = restriction.getBaseTypeName();

                // is this an enumeration?
                for (final Iterator iterator = restriction.getFacets().getIterator(); iterator.hasNext(); ) {
                    if (iterator.next() instanceof XmlSchemaEnumerationFacet) {
                        typeInfo.enumType = true;
                        break;
                    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.