Examples of XmlSchemaSimpleTypeRestriction


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

       
        XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
        simple.setName(getSchemaType().getLocalPart());
        root.addType(simple);
        root.getItems().add(simple);
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
        restriction.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
        simple.setContent(restriction);

        Object[] constants = getTypeClass().getEnumConstants();

        XmlSchemaObjectCollection facets = restriction.getFacets();
        for (Object constant : constants) {
            XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
            f.setValue(((Enum)constant).name());
            facets.add(f);
        }
View Full Code Here

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

            return;
        }
       
        // xmlschema:fixed
        XmlSchemaSimpleType fixedSimpleType = new XmlSchemaSimpleType(schema);
        XmlSchemaSimpleTypeRestriction fixedRestriction = new XmlSchemaSimpleTypeRestriction();
        fixedRestriction.setBaseTypeName(Constants.XSD_DECIMAL);
        XmlSchemaTotalDigitsFacet fixedTotalDigits = new XmlSchemaTotalDigitsFacet();
        fixedTotalDigits.setValue(digitsNode.toString());
        XmlSchemaFractionDigitsFacet fixedFractionDigits = new XmlSchemaFractionDigitsFacet();
        fixedFractionDigits.setValue(scaleNode.toString());
        fixedFractionDigits.setFixed(true);
        fixedRestriction.getFacets().add(fixedTotalDigits);
        fixedRestriction.getFacets().add(fixedFractionDigits);
        fixedSimpleType.setName(identifierNode.toString());
        fixedSimpleType.setContent(fixedRestriction);

        // add xmlschema:fixed
        getSchema().getItems().add(fixedSimpleType);
View Full Code Here

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

        // xmlschema:enum
        XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema);
        enumSchemaSimpleType.setName(enumNameNode.toString());
       
        XmlSchemaSimpleTypeRestriction enumSchemaSimpleTypeRestriction = new XmlSchemaSimpleTypeRestriction();
        enumSchemaSimpleTypeRestriction.setBaseTypeName(Constants.XSD_STRING);
       
        //XmlSchemaSimpleTypeContent xmlSchemaSimpleTypeContent = enumSchemaSimpleTypeRestriction;
        enumSchemaSimpleType.setContent(enumSchemaSimpleTypeRestriction);

       
        // corba:enum
        Enum corbaEnum = new Enum();
        corbaEnum.setQName(new QName(typeMap.getTargetNamespace(), enumNameNode.toString()));
        corbaEnum.setRepositoryID(CorbaConstants.REPO_STRING
                                  + enumNameNode.toString()
                                  + CorbaConstants.IDL_VERSION);
        corbaEnum.setType(enumSchemaSimpleType.getQName());
       
       
        AST node = enumNameNode.getNextSibling();
        while (node != null) {
            // xmlschema:enumeration
            XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet();
            enumeration.setValue(node.toString());
            enumSchemaSimpleTypeRestriction.getFacets().add(enumeration);

            // corba:enumerator
            Enumerator enumerator = new Enumerator();
            enumerator.setValue(node.toString());
            corbaEnum.getEnumerator().add(enumerator);
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

        }
        XmlSchemaSimpleType type = new XmlSchemaSimpleType(root, true);
        type.setName(getSchemaType().getLocalPart());
        XmlSchemaSimpleContentExtension ext = new XmlSchemaSimpleContentExtension();
        ext.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
        XmlSchemaSimpleTypeRestriction content = new XmlSchemaSimpleTypeRestriction();
        content.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
        type.setContent(content);
    }
View Full Code Here

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

    @Override
    public void writeSchema(XmlSchema root) {

        XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true);
        simple.setName(getSchemaType().getLocalPart());
        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
        restriction.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
        simple.setContent(restriction);

        Object[] constants = getTypeClass().getEnumConstants();

        List<XmlSchemaFacet> facets = restriction.getFacets();
        for (Object constant : constants) {
            XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
            f.setValue(((Enum)constant).name());
            facets.add(f);
        }
View Full Code Here

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

    }

    private void createImportedAttributeType(XmlSchema attributeTypeSchema) {
        XmlSchemaSimpleType attributeImportedType = new XmlSchemaSimpleType(attributeTypeSchema, true);
        attributeImportedType.setName("importedAttributeType");
        XmlSchemaSimpleTypeRestriction simpleContent = new XmlSchemaSimpleTypeRestriction();
        attributeImportedType.setContent(simpleContent);
        simpleContent.setBaseTypeName(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string"));
    }
View Full Code Here

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

     * @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

                    // Handle enumerations in here.
                    XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) schemaType;
                    XmlSchemaSimpleTypeContent content = xmlSchemaSimpleType.getContent();
                    if (content instanceof XmlSchemaSimpleTypeRestriction) {
                        // We only support restriction on xs:string.
                        XmlSchemaSimpleTypeRestriction simpleTypeRestriction =
                                (XmlSchemaSimpleTypeRestriction) content;
                        String elementName = innerElement.getName();
                        Object object = handleSimpleElement(payload, engine, elementName,
                                innerElement.getMinOccurs(),
                                simpleTypeRestriction.getBaseTypeName());
                        XmlSchemaObjectCollection facets = simpleTypeRestriction.getFacets();
                        Iterator iterator1 = facets.getIterator();
                        // Used to check whether the incoming value of the enumeration matches one thats defined in the
                        // schema.
                        boolean valueFound = false;
                        while (iterator1.hasNext()) {
View Full Code Here

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

            String targetNamespacePrefix = (String) targetNamespacePrefixMap.get(targetNameSpace);
            schemaTypeName = new QName(targetNameSpace, simpleName, targetNamespacePrefix);

            if (dataType instanceof EnumType) {
                XmlSchemaSimpleType simpleType = new XmlSchemaSimpleType(xmlSchema);
                XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
                restriction.setBaseTypeName(typeTable.getSimpleSchemaTypeName("java.lang.String"));
                simpleType.setContent(restriction);
                simpleType.setName(simpleName);

                XmlSchemaObjectCollection facets = restriction.getFacets();
                EnumType enumType = (EnumType) dataType;
                List enumMembers = enumType.getEnumMembers();
                for (int i = 0; i < enumMembers.size(); i++) {
                    facets.add(new XmlSchemaEnumerationFacet(enumMembers.get(i), false));
                }
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.