use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class TypesUtils method generateAnonymousScopedName.
public static Scope generateAnonymousScopedName(Scope scope, XmlSchema schema) {
Scope scopedName;
XmlSchemaType anonSchemaType;
int id = 0;
do {
id++;
StringBuilder name = new StringBuilder();
name.append('_');
name.append("Anon").append(Integer.toString(id));
name.append('_');
name.append(scope.tail());
scopedName = new Scope(scope.getParent(), name.toString());
QName scopedQName = new QName(schema.getTargetNamespace(), scopedName.toString());
anonSchemaType = schema.getTypeByName(scopedQName);
} while (anonSchemaType != null);
return scopedName;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ProcessorUtil method createWrappedElementsFromExtension.
private static List<WrapperElement> createWrappedElementsFromExtension(SchemaCollection schema, XmlSchemaComplexType type, int maxStackDepth) {
List<WrapperElement> qnames = new ArrayList<>();
XmlSchemaContent schemaContent = type.getContentModel().getContent();
if (!(schemaContent instanceof XmlSchemaComplexContentExtension) || maxStackDepth == 0) {
return qnames;
}
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) schemaContent;
QName baseTypeName = extension.getBaseTypeName();
XmlSchemaType baseType = schema.getTypeByQName(baseTypeName);
if (baseType instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexBaseType = (XmlSchemaComplexType) baseType;
if (complexBaseType.getParticle() == null && complexBaseType.getContentModel() != null) {
// continue up the extension ladder
qnames.addAll(createWrappedElementsFromExtension(schema, complexBaseType, maxStackDepth - 1));
} else if (complexBaseType.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence) complexBaseType.getParticle();
qnames.addAll(createWrappedElements(seq));
}
}
if (extension.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence) extension.getParticle();
qnames.addAll(createWrappedElements(xmlSchemaSeq));
}
return qnames;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project wso2-axis2-transports by wso2.
the class XMPPSender method getParameterListForOperation.
/**
* Retrieves list of parameter names & their type for a given operation
* @param operation
*/
private static String getParameterListForOperation(AxisOperation operation) {
// Logic copied from BuilderUtil.buildsoapMessage(...)
StringBuffer paramList = new StringBuffer();
AxisMessage axisMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
XmlSchemaElement xmlSchemaElement = axisMessage.getSchemaElement();
if (xmlSchemaElement != null) {
XmlSchemaType schemaType = xmlSchemaElement.getSchemaType();
if (schemaType instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexType = ((XmlSchemaComplexType) schemaType);
XmlSchemaParticle particle = complexType.getParticle();
if (particle instanceof XmlSchemaSequence || particle instanceof XmlSchemaAll) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) particle;
Iterator iterator = xmlSchemaGroupBase.getItems().getIterator();
while (iterator.hasNext()) {
XmlSchemaElement innerElement = (XmlSchemaElement) iterator.next();
QName qName = innerElement.getQName();
if (qName == null && innerElement.getSchemaTypeName().equals(org.apache.ws.commons.schema.constants.Constants.XSD_ANYTYPE)) {
break;
}
long minOccurs = innerElement.getMinOccurs();
boolean nillable = innerElement.isNillable();
String name = qName != null ? qName.getLocalPart() : innerElement.getName();
String type = innerElement.getSchemaTypeName().toString();
paramList.append("," + type + " " + name);
}
}
}
}
// remove first ","
String list = paramList.toString();
return list.replaceFirst(",", "");
}
use of org.apache.ws.commons.schema.XmlSchemaType 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);
}
}
}
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class ReflectionServiceFactoryBean method checkForElement.
protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(), getQualifyWrapperSchema());
XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
if (e != null) {
mpi.setXmlSchema(e);
return;
}
XmlSchema schema = si.getSchema();
// cached element is now invalid
si.setElement(null);
XmlSchemaElement el = new XmlSchemaElement(schema, true);
el.setName(mpi.getElementQName().getLocalPart());
el.setNillable(true);
XmlSchemaType tp = (XmlSchemaType) mpi.getXmlSchema();
if (tp == null) {
throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG, mpi.getName(), mpi.getMessageInfo().getName()));
}
el.setSchemaTypeName(tp.getQName());
mpi.setXmlSchema(el);
}
Aggregations