use of org.apache.ws.commons.schema.XmlSchemaForm in project cxf by apache.
the class WSDLASTVisitor method setQualified.
public void setQualified(boolean qualified) throws Exception {
if (qualified) {
XmlSchemaForm form = XmlSchemaForm.QUALIFIED;
schema.setAttributeFormDefault(form);
schema.setElementFormDefault(form);
}
}
use of org.apache.ws.commons.schema.XmlSchemaForm in project convertigo by convertigo.
the class SchemaUtils method createSchema.
public static XmlSchema createSchema(String prefix, String targetNamespace, String elementFormDefault, String attributeFormDefault) {
NamespaceMap nsMap = new NamespaceMap();
nsMap.add("xsd", Constants.URI_2001_SCHEMA_XSD);
nsMap.add(prefix, targetNamespace);
XmlSchemaCollection xmlSchemaCollection = createSchemaCollection(nsMap);
XmlSchema xmlSchema = new XmlSchema(targetNamespace, xmlSchemaCollection);
xmlSchema.setNamespaceContext(nsMap);
xmlSchema.setElementFormDefault(new XmlSchemaForm(elementFormDefault));
xmlSchema.setAttributeFormDefault(new XmlSchemaForm(attributeFormDefault));
return xmlSchema;
}
use of org.apache.ws.commons.schema.XmlSchemaForm in project convertigo by convertigo.
the class XmlSchemaBuilder method preBuildSchema.
private void preBuildSchema() throws EngineException {
try {
schema.setElementFormDefault(new XmlSchemaForm(project.getSchemaElementForm().name()));
schema.setAttributeFormDefault(new XmlSchemaForm(project.getSchemaElementForm().name()));
ConvertigoError.addXmlSchemaObjects(schema);
EngineStatistics.addXmlSchemaObjects(schema);
// static and read-only generation : references, transactions, sequences declaration
new WalkHelper() {
@Override
protected void walk(DatabaseObject databaseObject) throws Exception {
if (databaseObject instanceof ISchemaGenerator) {
// generate itself and add to the caller list
if (databaseObject instanceof ISchemaImportGenerator) {
// Import case
if (databaseObject instanceof ProjectSchemaReference) {
// done further in buildSchema
} else {
XmlSchemaImport schemaImport = ((ISchemaImportGenerator) databaseObject).getXmlSchemaObject(collection, schema);
if (schemaImport != null) {
SchemaMeta.setXmlSchemaObject(schema, databaseObject, schemaImport);
XmlSchemaUtils.add(schema, schemaImport);
}
}
} else if (databaseObject instanceof ISchemaIncludeGenerator) {
// Include case
if (databaseObject instanceof Transaction) {
XmlSchemaInclude schemaInclude = ((ISchemaIncludeGenerator) databaseObject).getXmlSchemaObject(collection, schema);
addSchemaIncludeObjects(databaseObject, schemaInclude.getSchema());
} else {
XmlSchemaInclude schemaInclude = ((ISchemaIncludeGenerator) databaseObject).getXmlSchemaObject(collection, schema);
SchemaMeta.setXmlSchemaObject(schema, databaseObject, schemaInclude);
XmlSchemaUtils.add(schema, schemaInclude);
}
} else if (databaseObject instanceof Sequence) {
// Sequence case
XmlSchemaElement element = ((Sequence) databaseObject).getXmlSchemaObject(collection, schema);
SchemaMeta.setXmlSchemaObject(schema, databaseObject, element);
XmlSchemaUtils.add(schema, element);
}
} else {
// doesn't generate schema, just deep walk
super.walk(databaseObject);
}
}
@Override
protected boolean before(DatabaseObject databaseObject, Class<? extends DatabaseObject> dboClass) {
// just walk references, transactions, sequences declaration
return Step.class.isAssignableFrom(dboClass) || Transaction.class.isAssignableFrom(dboClass) || Sequence.class.isAssignableFrom(dboClass) || Reference.class.isAssignableFrom(dboClass) || Connector.class.isAssignableFrom(dboClass);
}
protected void addSchemaIncludeObjects(DatabaseObject databaseObject, XmlSchema xmlSchema) {
if (xmlSchema != null) {
XmlSchemaObjectCollection c = xmlSchema.getItems();
Iterator<XmlSchemaObject> it = GenericUtils.cast(c.getIterator());
while (it.hasNext()) {
XmlSchemaObject xmlSchemaObject = it.next();
SchemaMeta.getReferencedDatabaseObjects(xmlSchemaObject).add(databaseObject);
if (xmlSchemaObject instanceof XmlSchemaImport) {
// ignore
} else if (xmlSchemaObject instanceof XmlSchemaInclude) {
XmlSchemaInclude schemaInclude = (XmlSchemaInclude) xmlSchemaObject;
addSchemaIncludeObjects(databaseObject, schemaInclude.getSchema());
} else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
XmlSchemaAttribute attribute = (XmlSchemaAttribute) xmlSchemaObject;
if (schema.getAttributes().getItem(attribute.getQName()) == null) {
schema.getAttributes().add(attribute.getQName(), attribute);
schema.getItems().add(attribute);
}
} else if (xmlSchemaObject instanceof XmlSchemaAttributeGroup) {
XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup) xmlSchemaObject;
if (schema.getAttributeGroups().getItem(attributeGroup.getName()) == null) {
schema.getAttributeGroups().add(attributeGroup.getName(), attributeGroup);
schema.getItems().add(attributeGroup);
}
} else if (xmlSchemaObject instanceof XmlSchemaGroup) {
XmlSchemaGroup group = (XmlSchemaGroup) xmlSchemaObject;
if (schema.getGroups().getItem(group.getName()) == null) {
schema.getGroups().add(group.getName(), group);
schema.getItems().add(group);
}
} else if (xmlSchemaObject instanceof XmlSchemaElement) {
XmlSchemaElement element = (XmlSchemaElement) xmlSchemaObject;
if (collection.getElementByQName(element.getQName()) == null && schema.getElementByName(element.getQName()) == null) {
schema.getElements().add(element.getQName(), element);
schema.getItems().add(element);
}
} else if (xmlSchemaObject instanceof XmlSchemaType) {
XmlSchemaType schemaType = (XmlSchemaType) xmlSchemaObject;
if (collection.getTypeByQName(schemaType.getQName()) == null && schema.getTypeByName(schemaType.getQName()) == null) {
schema.addType(schemaType);
schema.getItems().add(schemaType);
}
} else {
schema.getItems().add(xmlSchemaObject);
}
}
}
}
}.init(project);
} catch (Exception e) {
throw new EngineException("preBuildSchema failed", e);
}
}
Aggregations