ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1171201 - in /webservices/xmlschema/trunk/xmlschema-core/src: main/java/org/apache/ws/commons/schema/resolver/ test/java/tests/ test/resources/XMLSCHEMA-8/ test/resources/XMLSCHEMA-8/a/ test/resources/XMLSCHEMA-8/a/b/ test/resources/XMLSCH...
Date Thu, 15 Sep 2011 18:12:05 GMT
Author: dkulp
Date: Thu Sep 15 18:12:04 2011
New Revision: 1171201

URL: http://svn.apache.org/viewvc?rev=1171201&view=rev
Log:
[XMLSCHEMA-8] Fix problem with relative paths if a file URI is passed in
for system location.

Added:
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
  (with props)
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd 
 (with props)
    webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd 
 (with props)
Modified:
    webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
    webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ImportTest.java

Modified: webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java?rev=1171201&r1=1171200&r2=1171201&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
(original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/main/java/org/apache/ws/commons/schema/resolver/DefaultURIResolver.java
Thu Sep 15 18:12:04 2011
@@ -21,6 +21,8 @@ package org.apache.ws.commons.schema.res
 import java.io.File;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 
 import org.xml.sax.InputSource;
@@ -44,7 +46,16 @@ public class DefaultURIResolver implemen
 
         if (baseUri != null) {
             try {
-                File baseFile = new File(baseUri);
+                File baseFile = null;
+                try {
+                    URI uri = new URI(baseUri);
+                    baseFile = new File(uri);
+                    if (!baseFile.exists()) {
+                        baseFile = new File(baseUri);
+                    }
+                } catch (Throwable ex) {
+                    baseFile = new File(baseUri);
+                }
                 if (baseFile.exists()) {
                     baseUri = baseFile.toURI().toString();
                 } else if (collectionBaseURI != null) {

Modified: webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ImportTest.java
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ImportTest.java?rev=1171201&r1=1171200&r2=1171201&view=diff
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ImportTest.java (original)
+++ webservices/xmlschema/trunk/xmlschema-core/src/test/java/tests/ImportTest.java Thu Sep
15 18:12:04 2011
@@ -20,11 +20,13 @@
 package tests;
 
 import java.io.File;
+import java.io.FileInputStream;
 import java.net.URL;
 import java.util.List;
 
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
@@ -95,6 +97,32 @@ public class ImportTest extends Assert {
 
         assertNotNull(schema.getTypeByName(new QName("http://soapinterop.org/xsd2", "SOAPStruct")));
         assertNotNull(schema.getElementByName(new QName("http://soapinterop.org/xsd2", "SOAPWrapper")));
+    } 
+    
+    /**
+     * see whether we can parse the imported schemas using relative 
+     * directories and paths.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testSchemaImport4() throws Exception {
+        //No base works
+        File f = new File(Resources.asURI("XMLSCHEMA-8/a/b/c/s1.xsd"));
+        XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+        FileInputStream is = new FileInputStream(f);
+        XmlSchema schema = schemaCol.read(new StreamSource(is, f.toURI().toString()));
+        is.close();
+        assertNotNull(schema);
+        
+        //XMLSCHEMA-8
+        schemaCol = new XmlSchemaCollection();
+        String base = f.getParentFile().toString();
+        schemaCol.setBaseUri(base);
+        is = new FileInputStream(f);
+        schema = schemaCol.read(new StreamSource(is, f.toURI().toString()));
+        is.close();
+        assertNotNull(schema);
     }
     
     /**

Added: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd?rev=1171201&view=auto
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
(added)
+++ webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
Thu Sep 15 18:12:04 2011
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="http://xmlschema.apache.org/XmlSchema8"
+	xmlns:prog="http://xmlschema.apache.org/XmlSchema8"
+	xmlns:com="http://xml.test.com/Commun"
+	elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+	<xs:import namespace="http://xmlschema.apache.org/S2" schemaLocation="../../../a/b/s2.xsd"
/>
+
+	<xs:complexType name="S1Type">
+		<xs:sequence>
+			<xs:element ref="com:S2"></xs:element>
+			<xs:element ref="com:S3"></xs:element>
+		</xs:sequence>
+	</xs:complexType>
+
+	<xs:element name="S1" type="prog:S1Type"/>
+
+</xs:schema>
\ No newline at end of file

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/c/s1.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd?rev=1171201&view=auto
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd (added)
+++ webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd Thu
Sep 15 18:12:04 2011
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="http://xmlschema.apache.org/S2" 
+			xmlns:com="http://xmlschema.apache.org/S2" 
+			xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+			elementFormDefault="qualified" attributeFormDefault="qualified" version="1.0">
+
+	<xs:include schemaLocation="s3.xsd"/>
+
+	<xs:complexType name="S2Type">
+		<xs:sequence>
+			<xs:element name="MyString" type="xs:string" minOccurs="0"/>
+		</xs:sequence>
+	</xs:complexType>
+
+	<xs:element name="S2" type="com:S2Type"/>
+	
+</xs:schema>

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s2.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd
URL: http://svn.apache.org/viewvc/webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd?rev=1171201&view=auto
==============================================================================
--- webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd (added)
+++ webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd Thu
Sep 15 18:12:04 2011
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema targetNamespace="http://xmlschema.apache.org/S2" 
+			xmlns:com="http://xmlschema.apache.org/S2" 
+			xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+			elementFormDefault="qualified" attributeFormDefault="qualified" version="1.0">
+
+	<xs:complexType name="S3Type">
+		<xs:sequence>
+			<xs:element name="AString" type="xs:string" minOccurs="0"/>
+		</xs:sequence>
+	</xs:complexType>
+
+	<xs:element name="S3" type="com:S3Type"/>
+
+</xs:schema>

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: webservices/xmlschema/trunk/xmlschema-core/src/test/resources/XMLSCHEMA-8/a/b/s3.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message