use of org.apache.ws.commons.schema.XmlSchemaParticle in project tdi-studio-se by Talend.
the class AllTypeDialog method buildParameterFromCollection.
private void buildParameterFromCollection(XmlSchemaObjectCollection xmlSchemaObjectCollection, ParameterInfo parameter) {
// XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) xmlSchemaParticle;
// XmlSchemaObjectCollection xmlSchemaObjectCollection = xmlSchemaSequence.getItems();
int count = xmlSchemaObjectCollection.getCount();
for (int j = 0; j < count; j++) {
XmlSchemaObject xmlSchemaObject = xmlSchemaObjectCollection.getItem(j);
if (xmlSchemaObject instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaObject;
XmlSchemaObjectCollection items = xmlSchemaGroupBase.getItems();
if (items != null) {
buildParameterFromCollection(items, parameter);
}
} else if (xmlSchemaObject instanceof XmlSchemaAny) {
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName("_content_");
parameterSon.setParent(parameter);
parameter.getParameterInfos().add(parameterSon);
} else if (xmlSchemaObject instanceof XmlSchemaElement) {
XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) xmlSchemaObject;
String elementName = xmlSchemaElement.getName();
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName(elementName);
parameterSon.setParent(parameter);
Long min = xmlSchemaElement.getMinOccurs();
Long max = xmlSchemaElement.getMaxOccurs();
if (max - min > 1) {
parameterSon.setArraySize(-1);
parameterSon.setIndex("*");
}
parameter.getParameterInfos().add(parameterSon);
if (xmlSchemaElement.getSchemaTypeName() != null) {
String elementTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
if (elementTypeName != null && elementTypeName.equals("anyType")) {
parameterSon.setName(xmlSchemaElement.getName() + ":anyType");
}
parameterSon.setType(elementTypeName);
if (!WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
buileParameterFromTypes(elementTypeName, parameterSon);
}
} else if (xmlSchemaElement.getSchemaType() != null) {
if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaElement.getSchemaType();
XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
XmlSchemaObjectCollection childCollection = xmlSchemaGroupBase.getItems();
if (childCollection != null) {
buildParameterFromCollection(childCollection, parameterSon);
}
} else if (xmlSchemaElement.getSchemaTypeName() != null) {
String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
if (paraTypeName != null) {
parameter.setType(paraTypeName);
buileParameterFromTypes(paraTypeName, parameterSon);
}
}
} else if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaSimpleType) {
XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) xmlSchemaElement.getSchemaType();
String typeName = xmlSchemaSimpleType.getName();
if (typeName != null && typeName.equals("anyType")) {
ParameterInfo pSon = new ParameterInfo();
pSon.setName(xmlSchemaElement.getName() + "(anyType)");
pSon.setParent(parameter);
parameter.getParameterInfos().add(pSon);
}
parameter.setType(typeName);
}
} else if (xmlSchemaElement.getRefName() != null) {
String elementTypeName = xmlSchemaElement.getRefName().getLocalPart();
if (!WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
buildParameterFromElements(elementTypeName, parameterSon);
}
}
} else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute) xmlSchemaObject;
String elementName = xmlSchemaAttribute.getName();
ParameterInfo parameterSon = new ParameterInfo();
parameterSon.setName(elementName);
parameterSon.setParent(parameter);
parameter.getParameterInfos().add(parameterSon);
if (xmlSchemaAttribute.getSchemaTypeName() != null) {
String elementTypeName = xmlSchemaAttribute.getSchemaTypeName().getLocalPart();
parameterSon.setType(elementTypeName);
if (!WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
buileParameterFromTypes(elementTypeName, parameterSon);
}
} else if (xmlSchemaAttribute.getRefName() != null) {
String refName = xmlSchemaAttribute.getRefName().getLocalPart();
parameterSon.setType(refName);
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaParticle in project hale by halestudio.
the class XmlSchemaReader method createProperties.
/**
* Create the properties for the given complex type
*
* @param typeDef the definition of the declaring type
* @param item the complex type item
* @param schemaLocation the schema location
* @param schemaNamespace the scheme namspace
*/
private void createProperties(XmlTypeDefinition typeDef, XmlSchemaComplexType item, String schemaLocation, String schemaNamespace) {
// item:
// <complexType ...>
XmlSchemaContentModel model = item.getContentModel();
if (model != null) {
XmlSchemaContent content = model.getContent();
if (content instanceof XmlSchemaComplexContentExtension) {
// <complexContent>
// <extension base="...">
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
// particle (e.g. sequence)
if (extension.getParticle() != null) {
XmlSchemaParticle particle = extension.getParticle();
createPropertiesFromParticle(typeDef, particle, schemaLocation, schemaNamespace, false);
}
// attributes
XmlSchemaObjectCollection attributeCollection = extension.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// complex content does not have a value
// (only if it is mixed, which can override this setting)
typeDef.setConstraintIfNotSet(HasValueFlag.DISABLED);
// </extension>
// </complexContent>
} else if (content instanceof XmlSchemaComplexContentRestriction) {
// <complexContent>
// <restriction base="...">
XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
// particle (e.g. sequence)
if (restriction.getParticle() != null) {
XmlSchemaParticle particle = restriction.getParticle();
createPropertiesFromParticle(typeDef, particle, schemaLocation, schemaNamespace, false);
}
// attributes
XmlSchemaObjectCollection attributeCollection = restriction.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// complex content does not have a value
// (only if it is mixed, which can override this setting)
typeDef.setConstraintIfNotSet(HasValueFlag.DISABLED);
// </restriction>
// </complexContent>
} else if (content instanceof XmlSchemaSimpleContentExtension) {
// <simpleContent>
// <extension base="...">
XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) content;
// attributes
XmlSchemaObjectCollection attributeCollection = extension.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// </extension>
// </simpleContent>
} else if (content instanceof XmlSchemaSimpleContentRestriction) {
// <simpleContent>
// <restriction base="...">
XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) content;
// attributes
XmlSchemaObjectCollection attributeCollection = restriction.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
// </restriction>
// </simpleContent>
}
} else {
// no complex content (instead e.g. <sequence>)
XmlSchemaComplexType complexType = item;
// particle (e.g. sequence)
if (item.getParticle() != null) {
XmlSchemaParticle particle = complexType.getParticle();
createPropertiesFromParticle(typeDef, particle, schemaLocation, schemaNamespace, false);
}
// attributes
XmlSchemaObjectCollection attributeCollection = complexType.getAttributes();
if (attributeCollection != null) {
createAttributesFromCollection(attributeCollection, typeDef, null, schemaLocation, schemaNamespace);
}
}
// </complexType>
}
use of org.apache.ws.commons.schema.XmlSchemaParticle in project cxf by apache.
the class SchemaCollection method addCrossImports.
private void addCrossImports(XmlSchema schema, XmlSchemaContentModel contentModel) {
if (contentModel == null) {
return;
}
XmlSchemaContent content = contentModel.getContent();
if (content == null) {
return;
}
if (content instanceof XmlSchemaComplexContentExtension) {
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) content;
XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
addCrossImportsAttributeList(schema, extension.getAttributes());
XmlSchemaParticle particle = extension.getParticle();
if (particle instanceof XmlSchemaSequence) {
addCrossImports(schema, (XmlSchemaSequence) particle);
} else if (particle instanceof XmlSchemaChoice) {
addCrossImports(schema, (XmlSchemaChoice) particle);
} else if (particle instanceof XmlSchemaAll) {
addCrossImports(schema, (XmlSchemaAll) particle);
}
} else if (content instanceof XmlSchemaComplexContentRestriction) {
XmlSchemaComplexContentRestriction restriction = (XmlSchemaComplexContentRestriction) content;
XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
addCrossImportsAttributeList(schema, restriction.getAttributes());
} else if (content instanceof XmlSchemaSimpleContentExtension) {
XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension) content;
XmlSchemaUtils.addImportIfNeeded(schema, extension.getBaseTypeName());
addCrossImportsAttributeList(schema, extension.getAttributes());
} else if (content instanceof XmlSchemaSimpleContentRestriction) {
XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) content;
XmlSchemaUtils.addImportIfNeeded(schema, restriction.getBaseTypeName());
addCrossImportsAttributeList(schema, restriction.getAttributes());
}
}
use of org.apache.ws.commons.schema.XmlSchemaParticle 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.XmlSchemaParticle in project cxf by apache.
the class CorbaHandlerUtils method getXmlSchemaSequenceElement.
public static XmlSchemaElement getXmlSchemaSequenceElement(XmlSchemaObject schemaType, ServiceInfo serviceInfo) {
XmlSchemaObject stype = schemaType;
XmlSchemaElement el = null;
if (schemaType instanceof XmlSchemaElement) {
stype = ((XmlSchemaElement) schemaType).getSchemaType();
if (stype == null) {
stype = CorbaUtils.getXmlSchemaType(serviceInfo, ((XmlSchemaElement) schemaType).getRef().getTargetQName());
}
}
if (stype instanceof XmlSchemaComplexType) {
// only one element inside the XmlSchemaComplexType
XmlSchemaComplexType ctype = (XmlSchemaComplexType) stype;
XmlSchemaParticle group = ctype.getParticle();
/* This code seems to think that we're guaranteed a sequence here */
XmlSchemaSequence seq = (XmlSchemaSequence) group;
/* and an element in it, too */
el = (XmlSchemaElement) seq.getItems().get(0);
} else {
el = (XmlSchemaElement) schemaType;
}
return el;
}
Aggregations