Search in sources :

Example 6 with XmlSchemaEnumerationFacet

use of org.apache.ws.commons.schema.XmlSchemaEnumerationFacet in project cxf by apache.

the class EnumType method writeSchema.

@Override
public void writeSchema(XmlSchema root) {
    XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root, true);
    simple.setName(getSchemaType().getLocalPart());
    XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
    restriction.setBaseTypeName(Constants.XSD_STRING);
    simple.setContent(restriction);
    Object[] constants = getTypeClass().getEnumConstants();
    List<XmlSchemaFacet> facets = restriction.getFacets();
    for (Object constant : constants) {
        XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
        f.setValue(getValue(constant));
        facets.add(f);
    }
}
Also used : XmlSchemaFacet(org.apache.ws.commons.schema.XmlSchemaFacet) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaEnumerationFacet(org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)

Example 7 with XmlSchemaEnumerationFacet

use of org.apache.ws.commons.schema.XmlSchemaEnumerationFacet in project cxf by apache.

the class EnumVisitor method visit.

public void visit(AST enumNode) {
    // <enum_type> ::= "enum" <identifier> "{" <enumerator> {"," <enumerator>}* "}"
    // <enumerator> ::= <identifier>
    AST enumNameNode = enumNode.getFirstChild();
    Scope enumNameScope = new Scope(getScope(), enumNameNode);
    // xmlschema:enum
    XmlSchemaSimpleType enumSchemaSimpleType = new XmlSchemaSimpleType(schema, true);
    enumSchemaSimpleType.setName(mapper.mapToQName(enumNameScope));
    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(), enumNameScope.toString()));
    corbaEnum.setRepositoryID(enumNameScope.toIDLRepositoryID());
    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);
        node = node.getNextSibling();
    }
    // add corbaType
    typeMap.getStructOrExceptionOrUnion().add(corbaEnum);
    // REVISIT: are there assignments needed?
    setSchemaType(enumSchemaSimpleType);
    setCorbaType(corbaEnum);
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) AST(antlr.collections.AST) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaEnumerationFacet(org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)

Aggregations

XmlSchemaEnumerationFacet (org.apache.ws.commons.schema.XmlSchemaEnumerationFacet)7 XmlSchemaFacet (org.apache.ws.commons.schema.XmlSchemaFacet)5 XmlSchemaSimpleTypeRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction)5 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)4 XmlSchemaSimpleTypeContent (org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent)3 QName (javax.xml.namespace.QName)2 Enum (org.apache.cxf.binding.corba.wsdl.Enum)2 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)2 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)2 AST (antlr.collections.AST)1 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)1 TypeConstraint (eu.esdihumboldt.hale.common.schema.model.TypeConstraint)1 ValidationConstraint (eu.esdihumboldt.hale.common.schema.model.constraint.type.ValidationConstraint)1 UnionValidationConstraint (eu.esdihumboldt.hale.io.xsd.reader.internal.constraint.UnionValidationConstraint)1 AndValidator (eu.esdihumboldt.util.validator.AndValidator)1 DigitCountValidator (eu.esdihumboldt.util.validator.DigitCountValidator)1 EnumerationValidator (eu.esdihumboldt.util.validator.EnumerationValidator)1 LengthValidator (eu.esdihumboldt.util.validator.LengthValidator)1 NumberValidator (eu.esdihumboldt.util.validator.NumberValidator)1 OrValidator (eu.esdihumboldt.util.validator.OrValidator)1