You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/10/05 23:28:31 UTC
svn commit: r582399 - in /incubator/tuscany/java/sca/modules:
interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/
interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/
Author: rfeng
Date: Fri Oct 5 14:28:30 2007
New Revision: 582399
URL: http://svn.apache.org/viewvc?rev=582399&view=rev
Log:
Fix the XSD element resolving issue reported in TUSCANY-1814
Modified:
incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java
Modified: incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java?rev=582399&r1=582398&r2=582399&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java Fri Oct 5 14:28:30 2007
@@ -382,9 +382,7 @@
xsDefinition.setNamespace(element.getAttribute("targetNamespace"));
xsDefinition.setDocument(doc);
xsDefinition.setLocation(URI.create(doc.getDocumentURI() + "#" + index));
- XSDefinition resolved =
- contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition);
- wsdlDefinition.getXmlSchemas().add(resolved);
+ contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition);
index++;
}
}
Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java?rev=582399&r1=582398&r2=582399&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java Fri Oct 5 14:28:30 2007
@@ -19,6 +19,8 @@
package org.apache.tuscany.sca.interfacedef.wsdl.impl;
+import static org.apache.tuscany.sca.interfacedef.wsdl.impl.XSDefinitionImpl.getXmlSchemaObject;
+
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@@ -170,15 +172,13 @@
public XmlSchemaElement getXmlSchemaElement(QName name) {
XmlSchemaCollection schemaCollection = null;
for (XSDefinition xsd : schemas) {
- if (xsd.getSchemaCollection() != null) {
+ if (schemaCollection == null && xsd.getSchemaCollection() != null) {
schemaCollection = xsd.getSchemaCollection();
}
XmlSchema schema = xsd.getSchema();
- if (schema != null) {
- XmlSchemaElement element = schema.getElementByName(name);
- if (element != null) {
- return element;
- }
+ XmlSchemaElement element = getXmlSchemaObject(schema, name, XmlSchemaElement.class);
+ if (element != null) {
+ return element;
}
}
if (schemaCollection != null) {
@@ -197,11 +197,9 @@
schemaCollection = xsd.getSchemaCollection();
}
XmlSchema schema = xsd.getSchema();
- if (schema != null) {
- XmlSchemaType type = schema.getTypeByName(name);
- if (type != null) {
- return type;
- }
+ XmlSchemaType type = getXmlSchemaObject(schema, name, XmlSchemaType.class);
+ if (type != null) {
+ return type;
}
}
if (schemaCollection != null) {
Modified: incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java?rev=582399&r1=582398&r2=582399&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/XSDefinitionImpl.java Fri Oct 5 14:28:30 2007
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.interfacedef.wsdl.impl;
import java.net.URI;
+import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -27,6 +28,9 @@
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObject;
import org.apache.ws.commons.schema.XmlSchemaType;
import org.w3c.dom.Document;
@@ -159,9 +163,38 @@
return true;
}
+ public static <T extends XmlSchemaObject> T getXmlSchemaObject(XmlSchema schema, QName name, Class<T> type) {
+ if (schema != null) {
+ XmlSchemaObject object = null;
+ if (type == XmlSchemaElement.class) {
+ object = schema.getElementByName(name);
+ } else if (type == XmlSchemaType.class) {
+ object = schema.getTypeByName(name);
+ }
+ if (object != null) {
+ return type.cast(object);
+ }
+ for (Iterator i = schema.getIncludes().getIterator(); i.hasNext();) {
+ XmlSchemaObject obj = (XmlSchemaObject)i.next();
+ XmlSchema ext = null;
+ if (obj instanceof XmlSchemaInclude) {
+ ext = ((XmlSchemaInclude)obj).getSchema();
+ }
+ if (obj instanceof XmlSchemaImport) {
+ ext = ((XmlSchemaImport)obj).getSchema();
+ }
+ object = getXmlSchemaObject(ext, name, type);
+ if (object != null) {
+ return type.cast(object);
+ }
+ }
+ }
+ return null;
+ }
+
public XmlSchemaElement getXmlSchemaElement(QName name) {
if (schema != null) {
- XmlSchemaElement element = schema.getElementByName(name);
+ XmlSchemaElement element = getXmlSchemaObject(schema, name, XmlSchemaElement.class);
if (element != null) {
return element;
}
@@ -175,7 +208,7 @@
public XmlSchemaType getXmlSchemaType(QName name) {
if (schema != null) {
- XmlSchemaType type = schema.getTypeByName(name);
+ XmlSchemaType type = getXmlSchemaObject(schema, name, XmlSchemaType.class);
if (type != null) {
return type;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org