You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by di...@apache.org on 2006/02/02 22:08:54 UTC

svn commit: r374501 - in /webservices/commons/modules/XmlSchema: src/org/apache/ws/commons/schema/SchemaBuilder.java src/org/apache/ws/commons/schema/XmlSchemaCollection.java test/tests/ImportTest.java

Author: dims
Date: Thu Feb  2 13:08:50 2006
New Revision: 374501

URL: http://svn.apache.org/viewcvs?rev=374501&view=rev
Log:
prev iteration was specific to jdk15, added new methods to pass in the uri for the dom document/element

Modified:
    webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
    webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaCollection.java
    webservices/commons/modules/XmlSchema/test/tests/ImportTest.java

Modified: webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java?rev=374501&r1=374500&r2=374501&view=diff
==============================================================================
--- webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java (original)
+++ webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/SchemaBuilder.java Thu Feb  2 13:08:50 2006
@@ -52,12 +52,12 @@
 
 
 
-    XmlSchema build(Document doc, ValidationEventHandler veh) {
+    XmlSchema build(Document doc, String uri, ValidationEventHandler veh) {
         Element schemaEl = doc.getDocumentElement();
-        return handleXmlSchemaElement(schemaEl);
+        return handleXmlSchemaElement(schemaEl, uri);
     }
 
-    XmlSchema handleXmlSchemaElement(Element schemaEl) {
+    XmlSchema handleXmlSchemaElement(Element schemaEl, String uri) {
         // get all the attributes along with the namespace declns
 
         setNamespaceAttributes(schema, schemaEl);
@@ -67,7 +67,7 @@
                 "attributeFormDefault"));
         schema.setBlockDefault(this.getDerivation(schemaEl, "blockDefault"));
         schema.setFinalDefault(this.getDerivation(schemaEl, "finalDefault"));
-        schema.setSourceURI(schemaEl.getOwnerDocument().getBaseURI());
+        schema.setSourceURI(uri);
 
         /***********
          * for ( each childElement)

Modified: webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaCollection.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaCollection.java?rev=374501&r1=374500&r2=374501&view=diff
==============================================================================
--- webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaCollection.java (original)
+++ webservices/commons/modules/XmlSchema/src/org/apache/ws/commons/schema/XmlSchemaCollection.java Thu Feb  2 13:08:50 2006
@@ -197,7 +197,7 @@
             docFac.setNamespaceAware(true);
             DocumentBuilder builder = docFac.newDocumentBuilder();
             Document doc = builder.parse(inputSource);
-            return read(doc, veh);
+            return read(doc, inputSource.getSystemId(), veh);
         } catch (ParserConfigurationException e) {
             throw new XmlSchemaException(e.getMessage());
         } catch (IOException e) {
@@ -225,12 +225,22 @@
 
     public XmlSchema read(Document doc, ValidationEventHandler veh) {
         SchemaBuilder builder = new SchemaBuilder(this);
-        return builder.build(doc, veh);
+        return builder.build(doc, null, veh);
     }
 
     public XmlSchema read(Element elem) {
         SchemaBuilder builder = new SchemaBuilder(this);
-        return builder.handleXmlSchemaElement(elem);
+        return builder.handleXmlSchemaElement(elem, null);
+    }
+    
+    public XmlSchema read(Document doc, String uri, ValidationEventHandler veh) {
+        SchemaBuilder builder = new SchemaBuilder(this);
+        return builder.build(doc, uri, veh);
+    }
+
+    public XmlSchema read(Element elem, String uri) {
+        SchemaBuilder builder = new SchemaBuilder(this);
+        return builder.handleXmlSchemaElement(elem, uri);
     }
 
     /**

Modified: webservices/commons/modules/XmlSchema/test/tests/ImportTest.java
URL: http://svn.apache.org/viewcvs/webservices/commons/modules/XmlSchema/test/tests/ImportTest.java?rev=374501&r1=374500&r2=374501&view=diff
==============================================================================
--- webservices/commons/modules/XmlSchema/test/tests/ImportTest.java (original)
+++ webservices/commons/modules/XmlSchema/test/tests/ImportTest.java Thu Feb  2 13:08:50 2006
@@ -6,6 +6,7 @@
 import org.w3c.dom.Document;
 
 import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -43,14 +44,15 @@
      * @throws Exception
      */
     public void testSchemaImport2() throws Exception{
+        File file = new File("test-resources/importBase.xsd");
         //create a DOM document
         DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
         documentBuilderFactory.setNamespaceAware(true);
         Document doc = documentBuilderFactory.newDocumentBuilder().
-                parse("test-resources/importBase.xsd");
+                parse(file.toURL().toString());
 
         XmlSchemaCollection schemaCol = new XmlSchemaCollection();
-        XmlSchema schema = schemaCol.read(doc,null);
+        XmlSchema schema = schemaCol.read(doc,file.toURL().toString(),null);
         assertNotNull(schema);
 
     }