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);
}
}
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);
}
Aggregations