use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLToCorbaBinding method addCorbaElements.
private void addCorbaElements(XmlSchema xmlSchemaTypes) throws Exception {
Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
for (XmlSchemaElement el : elements.values()) {
QName elName = el.getQName();
XmlSchemaType schemaType = el.getSchemaType();
if (elName == null) {
elName = el.getRef().getTargetQName();
schemaType = helper.getSchemaType(elName);
}
boolean anonymous;
if (schemaType == null) {
anonymous = true;
} else {
anonymous = WSDLTypes.isAnonymous(schemaType.getName());
}
if (schemaType != null) {
XmlSchemaAnnotation annotation = null;
if (el.getAnnotation() != null) {
annotation = el.getAnnotation();
}
// this situation won't be handled. REVISIT.
if (annotation != null) {
XmlSchemaAppInfo appInfo = null;
for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
if (ann instanceof XmlSchemaAppInfo) {
appInfo = (XmlSchemaAppInfo) ann;
break;
}
}
if (appInfo != null) {
NodeList nlist = appInfo.getMarkup();
Node node = nlist.item(0);
String info = node.getNodeValue();
info = info.trim();
String annotationBindingName = "";
if ("corba:binding=".equals(info.substring(0, 14))) {
annotationBindingName = info.substring(14);
}
if (bindingName.equals(annotationBindingName)) {
annotation = null;
}
}
}
CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, elName, schemaType, annotation, anonymous);
if (el.isNillable()) {
QName uname = helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
corbaTypeImpl = helper.createNillableUnion(uname, helper.checkPrefix(elName), helper.checkPrefix(corbaTypeImpl.getQName()), isQualified);
}
if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLTypes method isOMGUnion.
public static boolean isOMGUnion(XmlSchemaComplexType type) {
boolean isUnion = false;
if (type.getParticle() instanceof XmlSchemaSequence && type.getAttributes().isEmpty()) {
XmlSchemaSequence stype = (XmlSchemaSequence) type.getParticle();
if (stype.getItems().size() == 2) {
XmlSchemaParticle st1 = (XmlSchemaParticle) stype.getItems().get(0);
XmlSchemaParticle st2 = (XmlSchemaParticle) stype.getItems().get(1);
XmlSchemaElement discEl = null;
if (st1 instanceof XmlSchemaChoice && st2 instanceof XmlSchemaElement) {
isUnion = true;
discEl = (XmlSchemaElement) st2;
} else if (st2 instanceof XmlSchemaChoice && st1 instanceof XmlSchemaElement) {
isUnion = true;
discEl = (XmlSchemaElement) st1;
}
if (isUnion && !"discriminator".equals(discEl.getQName().getLocalPart())) {
isUnion = false;
}
}
}
return isUnion;
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLParameter method processWrappedOutputParams.
private void processWrappedOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
Output output = operation.getOutput();
if (output != null) {
Message msg = output.getMessage();
Part part = (Part) msg.getOrderedParts(null).iterator().next();
XmlSchemaComplexType schemaType = null;
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el == null) {
return;
}
if (el.getSchemaType() != null) {
schemaType = (XmlSchemaComplexType) el.getSchemaType();
}
XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
if (seq != null) {
for (XmlSchemaSequenceMember seqMember : seq.getItems()) {
if (seqMember instanceof XmlSchemaElement) {
el = (XmlSchemaElement) seqMember;
processWrappedOutputParam(wsdlToCorbaBinding, el, inputs, outputs);
}
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLParameter method processInputParams.
private void processInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
Input input = operation.getInput();
if (input != null) {
Message msg = input.getMessage();
List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
for (Part part : parts) {
XmlSchemaType schemaType = null;
boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
if (part.getElementName() != null && !isObjectRef) {
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el != null) {
if (el.getSchemaType() != null) {
schemaType = el.getSchemaType();
}
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
if (paramtype != null) {
inputs.add(paramtype);
}
}
} else if (part.getTypeName() != null) {
schemaType = getType(part, xmlSchemaList);
QName typeName = part.getTypeName();
if (isObjectRef) {
typeName = part.getElementName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
ParamType paramtype = createParam(wsdlToCorbaBinding, "in", part.getName(), idltype);
if (paramtype != null) {
inputs.add(paramtype);
}
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLParameter method processOutputParams.
private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
Output output = operation.getOutput();
if (output != null) {
Message msg = output.getMessage();
List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
for (Part part : parts) {
XmlSchemaType schemaType = null;
// check if in input list
String mode = "out";
ParamType paramtype = null;
boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
for (int x = 0; x < inputs.size(); x++) {
paramtype = null;
ParamType d2 = inputs.get(x);
if (part.getElementName() != null && !isObjectRef) {
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el != null) {
if (el.getSchemaType() != null) {
schemaType = el.getSchemaType();
}
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
inputs.remove(x);
paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
inputs.add(paramtype);
}
}
} else {
schemaType = getType(part, xmlSchemaList);
QName typeName = part.getTypeName();
if (isObjectRef) {
typeName = part.getElementName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
inputs.remove(x);
paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
inputs.add(paramtype);
}
}
}
if (paramtype == null) {
if (part.getElementName() != null && !isObjectRef) {
XmlSchemaElement el = getElement(part, xmlSchemaList);
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
} else {
QName typeName = part.getTypeName();
if (isObjectRef) {
typeName = part.getElementName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
}
if (paramtype != null) {
outputs.add(paramtype);
}
}
}
}
}
Aggregations