use of org.apache.cxf.common.xmlschema.SchemaCollection in project cxf by apache.
the class CorbaUtils method getXmlSchemaType.
public static XmlSchemaType getXmlSchemaType(ServiceInfo serviceInfo, QName name) {
XmlSchemaType result = null;
if ((name != null) && (serviceInfo != null)) {
SchemaCollection col = serviceInfo.getXmlSchemaCollection();
result = col.getTypeByQName(name);
if (result == null) {
// check the name, if it is an element
XmlSchemaElement el = col.getElementByQName(name);
if (el != null) {
result = el.getSchemaType();
}
}
}
return result;
}
use of org.apache.cxf.common.xmlschema.SchemaCollection in project cxf by apache.
the class SourceDataBinding method initialize.
public void initialize(Service service) {
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();
if (schemaCollection.getXmlSchemas().length > 1) {
// Schemas are already populated.
continue;
}
new ServiceModelVisitor(serviceInfo) {
public void begin(MessagePartInfo part) {
if (part.getTypeQName() != null || part.getElementQName() != null) {
return;
}
part.setTypeQName(Constants.XSD_ANYTYPE);
}
}.walk();
}
}
use of org.apache.cxf.common.xmlschema.SchemaCollection in project cxf by apache.
the class SchemaUtil method getSchemas.
public void getSchemas(final Definition def, final ServiceInfo serviceInfo) {
SchemaCollection schemaCol = serviceInfo.getXmlSchemaCollection();
getSchemas(def, schemaCol, serviceInfo);
}
use of org.apache.cxf.common.xmlschema.SchemaCollection in project cxf by apache.
the class ReflectionServiceFactoryBean method getOrCreateSchema.
private SchemaInfo getOrCreateSchema(ServiceInfo serviceInfo, String namespaceURI, boolean qualified) {
for (SchemaInfo s : serviceInfo.getSchemas()) {
if (s.getNamespaceURI().equals(namespaceURI)) {
return s;
}
}
SchemaInfo schemaInfo = new SchemaInfo(namespaceURI);
SchemaCollection col = serviceInfo.getXmlSchemaCollection();
XmlSchema schema = col.getSchemaByTargetNamespace(namespaceURI);
if (schema != null) {
schemaInfo.setSchema(schema);
serviceInfo.addSchema(schemaInfo);
return schemaInfo;
}
schema = col.newXmlSchemaInCollection(namespaceURI);
if (qualified) {
schema.setElementFormDefault(XmlSchemaForm.QUALIFIED);
}
schemaInfo.setSchema(schema);
Map<String, String> explicitNamespaceMappings = this.getDataBinding().getDeclaredNamespaceMappings();
if (explicitNamespaceMappings == null) {
explicitNamespaceMappings = Collections.emptyMap();
}
NamespaceMap nsMap = new NamespaceMap();
for (Map.Entry<String, String> mapping : explicitNamespaceMappings.entrySet()) {
nsMap.add(mapping.getValue(), mapping.getKey());
}
if (!explicitNamespaceMappings.containsKey(WSDLConstants.NS_SCHEMA_XSD)) {
nsMap.add(WSDLConstants.NP_SCHEMA_XSD, WSDLConstants.NS_SCHEMA_XSD);
}
if (!explicitNamespaceMappings.containsKey(serviceInfo.getTargetNamespace())) {
nsMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, serviceInfo.getTargetNamespace());
}
schema.setNamespaceContext(nsMap);
serviceInfo.addSchema(schemaInfo);
return schemaInfo;
}
use of org.apache.cxf.common.xmlschema.SchemaCollection in project cxf by apache.
the class ReflectionServiceFactoryBean method fillInSchemaCrossreferences.
/**
* Code elsewhere in this function will fill in the name of the type of an
* element but not the reference to the type. This function fills in the
* type references. This does not set the type reference for elements that
* are declared as refs to other elements. It is a giant pain to find them,
* since they are not (generally) root elements and the code would have to
* traverse all the types to find all of them. Users should look them up
* through the collection, that's what it is for.
*/
private void fillInSchemaCrossreferences() {
Service service = getService();
for (ServiceInfo serviceInfo : service.getServiceInfos()) {
SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();
// type.
for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
Map<QName, XmlSchemaElement> elementsTable = schemaInfo.getSchema().getElements();
for (XmlSchemaElement element : elementsTable.values()) {
if (element.getSchemaType() == null) {
QName typeName = element.getSchemaTypeName();
if (typeName != null) {
XmlSchemaType type = schemaCollection.getTypeByQName(typeName);
if (type == null) {
Message message = new Message("REFERENCE_TO_UNDEFINED_TYPE", LOG, element.getQName(), typeName, service.getName());
LOG.severe(message.toString());
} else {
element.setSchemaType(type);
}
}
}
}
}
}
}
Aggregations