summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/trunk/modules
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2011-04-13 10:32:15 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2011-04-13 10:32:15 +0000
commit0548f00a2d2a342026d514f4f69a98a398673da8 (patch)
tree612fec2c7a86d30cf69b334dfb717f131746ee52 /sca-java-1.x/trunk/modules
parent022b1049dc7c384984ed673374c3ca643d52ea79 (diff)
TUSCANY-3859: Update "no namespace" type references in xs:extension schema elements
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1091732 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java77
1 files changed, 46 insertions, 31 deletions
diff --git a/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
index 00a767c089..ecd11dd452 100644
--- a/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
+++ b/sca-java-1.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
@@ -728,41 +728,56 @@ public class Interface2WSDLGenerator {
_import.getParentNode().removeChild(_import);
}
- // look for any type attributes that refer to the
- // node being merged
- NodeList elements = refSchema.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema","element");
- for (int k = 0; k < elements.getLength(); k++){
- Element element = (Element) elements.item(k);
- if (element != null && element.getAttributes() != null) {
- Node type = element.getAttributes().getNamedItem("type");
-
- if (type != null &&
- type.getNodeValue().equals(typeName)){
- if (xsDef.getNamespace().equals(defaultNamespace)){
- // double check that there is a "tns" namespace shortname specified
- String tnsNamespace = refSchema.getDocumentElement().getAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
-
- if (tnsNamespace == null || tnsNamespace.length() == 0) {
- refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns", defaultNamespace);
- }
-
- // just add "tns" in front of the type name as
- // we have merged the type into this schema
- type.setNodeValue("tns:" + type.getNodeValue());
- } else {
- // add a namespace
- refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:__nnns", defaultNamespace);
-
- // prefix the type name with the namespace
- type.setNodeValue("__nnns:" + type.getNodeValue());
- }
- }
- }
- }
+ // TUSCANY-3859: Look for any attributes that refer to the node being merged
+ fixUpNoNamespaceAttributes("element", "type", xsDef, typeName, defaultNamespace);
+ fixUpNoNamespaceAttributes("extension", "base", xsDef, typeName, defaultNamespace);
}
}
}
+ /**
+ * TUSCANY-3859
+ * Correct any schema attributes that used to point to types in the no namespace schema
+ *
+ * @param elementName
+ * @param attributeName
+ * @param xsDef
+ * @param defaultNamespace
+ */
+ private void fixUpNoNamespaceAttributes(String elementName, String attributeName,
+ XSDefinition xsDef, String typeName, String defaultNamespace) {
+ Document refSchema = xsDef.getDocument();
+ NodeList elements = refSchema.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", elementName);
+ for (int k = 0; k < elements.getLength(); k++){
+ Element element = (Element) elements.item(k);
+ if (element != null && element.getAttributes() != null) {
+ Node type = element.getAttributes().getNamedItem(attributeName);
+
+ if (type != null &&
+ type.getNodeValue().equals(typeName)){
+ if (xsDef.getNamespace().equals(defaultNamespace)){
+ // double check that there is a "tns" namespace shortname specified
+ String tnsNamespace = refSchema.getDocumentElement().getAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
+
+ if (tnsNamespace == null || tnsNamespace.length() == 0) {
+ refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns", defaultNamespace);
+ }
+
+ // just add "tns" in front of the type name as
+ // we have merged the type into this schema
+ type.setNodeValue("tns:" + type.getNodeValue());
+ } else {
+ // add a namespace
+ refSchema.getDocumentElement().setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:__nnns", defaultNamespace);
+
+ // prefix the type name with the namespace
+ type.setNodeValue("__nnns:" + type.getNodeValue());
+ }
+ }
+ }
+ }
+ }
+
/*
* Just used when debugging DOM problems
*/