Author: dims
Date: Tue Apr 15 08:34:38 2008
New Revision: 648283

URL: http://svn.apache.org/viewvc?rev=648283&view=rev
Log:
Fix Regression found by woden folks - 
http://markmail.org/message/zvmjz2jrxegsrvfz

Added:
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden-2.xsd
    
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden.xsd
Modified:
    
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
    
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java?rev=648283&r1=648282&r2=648283&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/main/java/org/apache/ws/commons/schema/XmlSchema.java
 Tue Apr 15 08:34:38 2008
@@ -101,10 +101,6 @@
      * @param parent the parent collection.
      */
     public XmlSchema(String namespace, String systemId, XmlSchemaCollection 
parent) {
-         this.parent = parent;
-       if (namespace == null) {
-               namespace = "";
-        }
         this.parent = parent;
         attributeFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
         elementFormDefault = new XmlSchemaForm(XmlSchemaForm.UNQUALIFIED);
@@ -120,6 +116,9 @@
         schemaTypes = new XmlSchemaObjectTable();
 
         syntacticalTargetNamespace = logicalTargetNamespace = namespace;
+        if (logicalTargetNamespace == null) {
+             logicalTargetNamespace = "";
+         }
         if(parent != null) {
                XmlSchemaCollection.SchemaKey schemaKey =
                        new 
XmlSchemaCollection.SchemaKey(this.logicalTargetNamespace, systemId);

Modified: 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java?rev=648283&r1=648282&r2=648283&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java
 (original)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/IncludeTest.java
 Tue Apr 15 08:34:38 2008
@@ -143,6 +143,28 @@
         assertNotNull(schemaCol.getTypeByQName(new 
QName("http://tns.demo.org";, "XdwsGroupId")));
        }
 
+
+    /**
+     * Test importing a schema without namespace into a schema
+     * with namespace.
+     */
+    public void testIncludeSchemaWithoutNamespace() throws Exception {
+        String uri = Resources.asURI("woden.xsd");
+        InputSource is = new InputSource(new FileInputStream(uri));
+        is.setSystemId(uri);
+        XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+        XmlSchema schema = schemaCol.read(is, null);
+
+        XmlSchemaObjectCollection c = schema.getIncludes();
+        assertEquals(1, c.getCount());
+        
+        XmlSchemaInclude schemaInclude = (XmlSchemaInclude)c.getItem(0);
+        assertNotNull(schemaInclude);
+
+        XmlSchema schema2 = schemaInclude.getSchema();
+        assertNull(schema2.getTargetNamespace());
+    }
+
     /**
      * Schema included defined xmlns="http://www.w3.org/2001/XMLSchema";
      * @throws Exception

Added: 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden-2.xsd
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden-2.xsd?rev=648283&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden-2.xsd 
(added)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden-2.xsd 
Tue Apr 15 08:34:38 2008
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
+       <xsd:complexType name="cinfoct">
+               <xsd:sequence>
+                       <xsd:element name="customerSurname" type="xsd:string" />
+                       <xsd:element name="customerForname" type="xsd:string" />
+                       <xsd:element name="branchCode">
+                               <xsd:simpleType>
+                                       <xsd:restriction base="xsd:string">
+                                               <xsd:pattern
+                                                       
value="[0-9]{2}[\-][0-9]{2}[\-][0-9]{2}" />
+                                       </xsd:restriction>
+                               </xsd:simpleType>
+                       </xsd:element>
+               </xsd:sequence>
+       </xsd:complexType>
+       <xsd:element name="custInfo" type="cinfoct" />
+       <xsd:complexType name="accinfct">
+               <xsd:sequence maxOccurs="unbounded" minOccurs="0">
+                       <xsd:element name="accName">
+                               <xsd:simpleType>
+                                       <xsd:restriction base="xsd:string">
+                                               <xsd:enumeration value="Cheque" 
/>
+                                               <xsd:enumeration value="Credit" 
/>
+                                               <xsd:enumeration 
value="Savings" />
+                                               <xsd:enumeration value="Loan" />
+                                       </xsd:restriction>
+                               </xsd:simpleType>
+                       </xsd:element>
+                       <xsd:element name="accNumber">
+                               <xsd:simpleType>
+                                       <xsd:restriction base="xsd:string">
+                                               <xsd:pattern value="[0-9]{12}" 
/>
+                                       </xsd:restriction>
+                               </xsd:simpleType>
+                       </xsd:element>
+                       <xsd:element name="accBalance">
+                               <xsd:simpleType>
+                                       <xsd:restriction base="xsd:decimal">
+                                               <xsd:fractionDigits value="2" />
+                                       </xsd:restriction>
+                               </xsd:simpleType>
+                       </xsd:element>
+               </xsd:sequence>
+       </xsd:complexType>
+       <xsd:element name="accInfo" type="accinfct" />
+</xsd:schema>

Added: 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden.xsd
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden.xsd?rev=648283&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden.xsd 
(added)
+++ 
webservices/commons/trunk/modules/XmlSchema/src/test/test-resources/woden.xsd 
Tue Apr 15 08:34:38 2008
@@ -0,0 +1,4 @@
+<xsd:schema targetNamespace="http://example.org/getBalance/";
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
+       <xsd:include schemaLocation="woden-2.xsd" />
+</xsd:schema>
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to