diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-12 20:40:20 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-12 20:40:20 +0000 |
commit | b46cd2bd0f57b0385883b1b5a8c12711ee68c007 (patch) | |
tree | 77e50f25792123db190980d02fbdd9e435436f6e /branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java | |
parent | b53525ea9d707d947d4b3eeace009ac5b130b4ef (diff) |
Fix TUSCANY-2531
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685307 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java')
-rw-r--r-- | branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 2e8e34853e..be87ec611b 100644 --- a/branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/branches/sca-java-1.3/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -76,6 +76,8 @@ import org.apache.ws.commons.schema.XmlSchemaException; import org.apache.ws.commons.schema.utils.NamespaceMap; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * @version $Rev: 670103 $ $Date: 2008-06-21 01:35:00 +0100 (Sat, 21 Jun 2008) $ @@ -325,7 +327,10 @@ public class Interface2WSDLGenerator { } QName typeName = element.getType().getQName(); String nsURI = typeName.getNamespaceURI(); - if ("".equals(nsURI) || targetNS.equals(nsURI)) { + if ("".equals(nsURI)) { + xsElement.setAttribute("type", typeName.getLocalPart()); + addSchemaImport(schema, "", schemaDoc); + } else if (targetNS.equals(nsURI)) { xsElement.setAttribute("type", typeName.getLocalPart()); } else if (SCHEMA_NS.equals(nsURI)) { xsElement.setAttribute("type", "xs:" + typeName.getLocalPart()); @@ -336,6 +341,7 @@ public class Interface2WSDLGenerator { prefix = "ns" + i++; prefixMap.put(nsURI, prefix); schema.setAttributeNS(XMLNS_NS, "xmlns:" + prefix, nsURI); + addSchemaImport(schema, nsURI, schemaDoc); } xsElement.setAttribute("type", prefix + ":" + typeName.getLocalPart()); } @@ -354,7 +360,26 @@ public class Interface2WSDLGenerator { return definition; } - + + private static void addSchemaImport(Element schema, String nsURI, Document schemaDoc) { + Element imp = schemaDoc.createElementNS(SCHEMA_NS, "xs:import"); + if (!"".equals(nsURI)) { + imp.setAttribute("namespace", nsURI); + } + NodeList childNodes = schema.getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node childNode = childNodes.item(i); + if (childNode instanceof Element) { + schema.insertBefore(imp, childNode); + imp = null; + break; + } + } + if (imp != null) { + schema.appendChild(imp); + } + } + private void addSchemaExtension(XSDefinition xsDef, XmlSchemaCollection schemaCollection, WSDLDefinition wsdlDefinition, |