use of org.apache.ws.commons.schema.XmlSchemaAnnotation in project cxf by apache.
the class WSDLToCorbaBinding method addCorbaElements.
private void addCorbaElements(CorbaType corbaTypeImpl, 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 = false;
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;
}
}
}
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.XmlSchemaAnnotation in project cxf by apache.
the class WSDLParameter method getIdlType.
private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, QName typeName, boolean nill) throws Exception {
QName idltype = null;
CorbaType corbaTypeImpl = null;
if (schemaType == null) {
corbaTypeImpl = (CorbaType) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
if (nill) {
QName qname = corbaTypeImpl.getQName();
idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
} else {
if (corbaTypeImpl == null) {
XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
XmlSchemaAnnotation annotation = null;
if (schemaObj instanceof XmlSchemaElement) {
XmlSchemaElement el = (XmlSchemaElement) schemaObj;
schemaType = el.getSchemaType();
annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
}
idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
} else {
idltype = corbaTypeImpl.getQName();
}
}
} else {
// We need to get annotation information for the schema type we are
// about to pass in.
// This is used to produce the correct object reference type.
XmlSchemaElement schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
XmlSchemaAnnotation annotation = null;
if (schemaObj != null) {
annotation = schemaObj.getAnnotation();
}
idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
}
return idltype;
}
use of org.apache.ws.commons.schema.XmlSchemaAnnotation in project cxf by apache.
the class ObjectReferenceVisitor method isDuplicateReference.
private void isDuplicateReference(QName referenceName, QName bindingName, Scope refScope, XmlSchemaType wsaType, AST node) {
XmlSchema refSchema = null;
if (!mapper.isDefaultMapping()) {
String tns = mapper.map(refScope.getParent());
String refSchemaFileName = getWsdlVisitor().getOutputDir() + System.getProperty("file.separator") + refScope.getParent().toString("_") + ".xsd";
refSchema = manager.getXmlSchema(tns);
if (refSchema == null) {
refSchema = manager.createXmlSchema(tns, wsdlVisitor.getSchemas());
}
addWSAddressingImport(refSchema);
manager.addXmlSchemaImport(schema, refSchema, refSchemaFileName);
} else {
refSchema = schema;
}
// we have, then there is no need to add it to the schema again.
if (!isReferenceSchemaTypeDefined(referenceName, refSchema)) {
// We need to add a new element definition to the schema section of our WSDL.
// For custom endpoint types, this should contain an annotation which points
// to the binding which will be used for this endpoint type.
XmlSchemaElement refElement = new XmlSchemaElement(schema, true);
refElement.setName(referenceName.getLocalPart());
refElement.setSchemaType(wsaType);
refElement.setSchemaTypeName(wsaType.getQName());
// Create an annotation which contains the CORBA binding for the element
XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
XmlSchemaAppInfo appInfo = new XmlSchemaAppInfo();
try {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.newDocument();
Element el = doc.createElement("appinfo");
el.setTextContent("corba:binding=" + bindingName.getLocalPart());
// TODO: This is correct but the appinfo markup is never added to the
// schema. Investigate.
appInfo.setMarkup(el.getChildNodes());
} catch (ParserConfigurationException ex) {
throw new RuntimeException("[ObjectReferenceVisitor: error creating endpoint schema]");
}
annotation.getItems().add(appInfo);
refElement.setAnnotation(annotation);
}
}
Aggregations