Author: jkaputin
Date: Wed Sep 14 03:21:32 2005
New Revision: 280813

URL: http://svn.apache.org/viewcvs?rev=280813&view=rev
Log:
Change schema model from Xerces XML Schema API to 

ws-commons XmlSchema. Simplified the representation of 

schemas in Woden by removing the notion of different 

types of schema content models - now just XmlSchema 

will be used (although it is currently just DOM based,

so may need further support for StAX based parsing).

Modified:
    incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
    incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImpl.java
    
incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImportImpl.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java
    incubator/woden/java/src/org/apache/woden/schema/Schema.java
    incubator/woden/java/src/org/apache/woden/schema/SchemaImport.java
    incubator/woden/java/src/org/apache/woden/wsdl20/xml/TypesElement.java

Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Wed 
Sep 14 03:21:32 2005
@@ -20,10 +20,8 @@
 import org.apache.woden.internal.util.dom.DOMUtils;

 import org.apache.woden.internal.util.dom.QNameUtils;

 import org.apache.woden.internal.wsdl20.Constants;

-import org.apache.woden.internal.wsdl20.extensions.*;

 import org.apache.woden.schema.Schema;

 import org.apache.woden.schema.SchemaImport;

-import org.apache.woden.wsdl20.extensions.*;

 import org.apache.woden.wsdl20.xml.*;

 import org.w3c.dom.Attr;

 import org.w3c.dom.Document;

@@ -34,16 +32,7 @@
 

 //JK temporary imports (pending TODOs)

 

-import com.ibm.wsdl.util.xml.DOM2Writer;

-

-import org.apache.xerces.dom3.bootstrap.DOMImplementationRegistry;

-import org.apache.xerces.xs.XSImplementation;

-import org.apache.xerces.xs.XSLoader;

-import org.apache.xerces.xs.XSModel;

-

-import org.w3c.dom.ls.DOMImplementationLS;

-import org.w3c.dom.ls.LSInput;

-

+import org.apache.axis.xsd.xml.schema.*;  //TODO test ws-commons XmlSchema

 import temp.WSDLException;

 

 /**

@@ -203,101 +192,37 @@
     }

     

     /*

-     * TODO Initial schema parsing is specific to XML Schema. 

-     * Need generic support for other type systems.

-     * Consider extension architecture with serializer/deserializer.

-     * 

-     * TODO For now, use XML Schema API (Xerces XSModel) to represent

-     * schema and parse elements and types. This will create a Xerces

-     * parser dependency on the Woden DOM implementation (rather than  

-     * just a JAXP/SAX/DOM API dependency). To be considered further.

+     * TODO Testing with ws-commons XmlSchema

      */

-    private Schema parseSchemaInline(Element schemaEl,

+    private Schema parseSchema(Element schemaEl,

                                      TypesElement desc) 

                                      throws WSDLException

     {

         SchemaImpl schema = new SchemaImpl();

         

+        schema.setId(DOMUtils.getAttribute(schemaEl, Constants.ATTR_ID));

+        

         schema.setTargetNamespace(

             DOMUtils.getAttribute(schemaEl, Constants.ATTR_TARGET_NAMESPACE));

         

-        //TODO the type system will depend on the WSDL doc so consider 

-        //parameterizing it. Fixed with an XML Schema constant for now.

+        XmlSchemaCollection xsc = 

+            new XmlSchemaCollection();

         

-        schema.setContentModel(Constants.TYPE_XS_API);  //XML Schema API

+        XmlSchema xs = xsc.read(schemaEl);

         

-        //TODO currently only the XSModel is stored in Schema. 

-        //The DOM element representing the schema is not stored. 

-        //Either might be useful to an application dealing 

-        //with the underlying types (e.g. generator tooling). 

-        //So consider changing Schema so that it stores both. 

-        //Perhaps using a Map with a ContentModel/Content pair.

+        schema.setSchemaContent(xs);

         

-        try {

-            //create an LSInput object to hold the schema string

-            System.setProperty(DOMImplementationRegistry.PROPERTY,

-                "org.apache.xerces.dom.DOMImplementationSourceImpl");

-            DOMImplementationRegistry domRegistry = 

-                DOMImplementationRegistry.newInstance();

-

-            DOMImplementationLS domImpl = 

-                (DOMImplementationLS)domRegistry.getDOMImplementation("LS");

-

-            LSInput lsInput = domImpl.createLSInput();

-

-            //store the schema as a string in the LSInput 

-            String schemaString = DOM2Writer.nodeToString(schemaEl);

-            System.out.println(schemaString);

-            lsInput.setStringData(schemaString);

-            

-            //Use DOM level 3 bootstrap to get an XSModel of the schema

-            System.setProperty(DOMImplementationRegistry.PROPERTY,

-                "org.apache.xerces.dom.DOMXSImplementationSourceImpl");

-            DOMImplementationRegistry xsRegistry = 
DOMImplementationRegistry.newInstance();

-

-            XSImplementation xsImpl = 

-                (XSImplementation) 
xsRegistry.getDOMImplementation("XS-Loader");

-

-            XSLoader xsLoader = xsImpl.createXSLoader(null);

-            

-            XSModel xsModel = xsLoader.load(lsInput);

-            

-            schema.setContent(xsModel);

-            

-            /* 

-             * print out the schema elements

-             * 

-            XSNamedMap xsNamedMap = 
xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);

-            System.out.println("\nInline schema elements (" + 
xsNamedMap.getLength() +"):");

-            for(int i = 0; i < xsNamedMap.getLength(); i++) 

-            {

-                System.out.println( (xsNamedMap.item(i)).getName() );

-            }

-             */

-            

-        } catch (Exception e) {

-            // TODO consider appropriate exceptions

-            e.printStackTrace();

-        }

-

         return schema;

+

     }

 

     /*

-     * TODO Initial schema parsing is specific to XML Schema. 

-     * Need generic support for other type systems.

-     * Consider extension architecture with serializer/deserializer.

-     * 

-     * TODO For now, use XML Schema API (Xerces XSModel) to represent

-     * schema and parse elements and types. This will create a Xerces

-     * parser dependency on the Woden DOM implementation (rather than  

-     * just a JAXP/SAX/DOM API dependency). To be considered further.

+     * TODO Testing with ws-commons XmlSchema

      */

     private SchemaImport parseSchemaImport(Element importEl,

                                            TypesElement types) 

                                            throws WSDLException

     {

-        //TODO use extension architecture aka WSDL4J

         SchemaImportImpl schemaImport = new SchemaImportImpl();

         

         schemaImport.setNamespace(

@@ -306,48 +231,15 @@
         schemaImport.setSchemaLocation(

             DOMUtils.getAttribute(importEl, 
SchemaConstants.ATTR_SCHEMA_LOCATION));

         

-        //TODO currently only the XSModel is stored in Schema. 

-        //The DOM element representing the schema is not stored. 

-        //Either might be useful to an application dealing 

-        //with the underlying types (e.g. generator tooling). 

-        //So consider changing Schema so that it stores both. 

-        //Perhaps using a Map with a ContentModel/Content pair.

         

-        schemaImport.setContentModel(Constants.TYPE_XS_API);  //XML Schema API

+        //TODO use SAX/DOM to get schema Element for this import 

+        //and call parseSchema method to get Schema object to pass 

+        //to the setSchema method. Or create and InputSource with 

+        //the schema loc URI and use XmlSchemaCollection.read.

+        //schemaImport.setSchema(null);

         

-        try {

-            //Use DOM level 3 bootstrap to get an XSModel of the schema

-            System.setProperty(DOMImplementationRegistry.PROPERTY,

-                "org.apache.xerces.dom.DOMXSImplementationSourceImpl");

-            DOMImplementationRegistry xsRegistry = 
DOMImplementationRegistry.newInstance();

-

-            XSImplementation xsImpl = 

-                (XSImplementation) 
xsRegistry.getDOMImplementation("XS-Loader");

-

-            XSLoader xsLoader = xsImpl.createXSLoader(null);

-            

-            String sloc = schemaImport.getSchemaLocation();

-            XSModel xsModel = xsLoader.loadURI(sloc);

-            

-            schemaImport.setContent(xsModel);

-            

-            /*

-             * print out the schema elements

-             * 

-            XSNamedMap xsNamedMap = 
xsModel.getComponents(XSConstants.ELEMENT_DECLARATION);

-            System.out.println("\nImported schema elements (" + 
xsNamedMap.getLength() +"):");

-            for(int i = 0; i < xsNamedMap.getLength(); i++) 

-            {

-                System.out.println( (xsNamedMap.item(i)).getName() );

-            }

-             */

-

-        } catch (Exception e) {

-            // TODO consider appropriate exceptions

-            e.printStackTrace();

-        }

-

         return schemaImport;

+        

     }

 

     /*

@@ -383,7 +275,7 @@
             }

             else if 
(SchemaConstants.XSD_SCHEMA_QNAME_LIST.contains(tempElType))

             {

-                types.addSchema(parseSchemaInline(tempEl, types));

+                types.addSchema(parseSchema(tempEl, types));

             }

             else

             {


Modified: 
incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImpl.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImpl.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImpl.java 
Wed Sep 14 03:21:32 2005
@@ -5,8 +5,11 @@
 

 import org.apache.woden.schema.Schema;

 

+import org.apache.axis.xsd.xml.schema.XmlSchema;  //TODO test ws-commons 
XmlSchema

+

 /**

- * A wrapper for a schema element.

+ * Represents a schema element such as &lt;xs:schema&gt; and

+ * stores the schema contents as a <code>XmlSchema</code> object.

  * 

  * @author [EMAIL PROTECTED]

  */

@@ -14,9 +17,18 @@
     

     private String fTargetNamespace;

     private String fId;

-    private String fContentModel;

-    private Object fContent;

+    private XmlSchema fSchemaContent;

 

+    public void setId(String id)

+    {

+        this.fId = id;

+    }

+  

+    public String getId()

+    {

+        return this.fId;

+    }

+  

     /* (non-Javadoc)

      * @see 
org.apache.woden.wsdl20.extensions.Schema#setTargetNamespace(java.lang.String)

      */

@@ -33,34 +45,14 @@
         return this.fTargetNamespace;

     }

     

-    public void setId(String id)

+    public void setSchemaContent(XmlSchema xmlSchema)

     {

-        this.fId = id;

-    }

-  

-    public String getId()

-    {

-        return this.fId;

-    }

-  

-    public void setContentModel(String contentModel)

-    {

-        this.fContentModel = contentModel;

+        this.fSchemaContent = xmlSchema;

     }

     

-    public String getContentModel()

+    public XmlSchema getSchemaContent()

     {

-        return this.fContentModel;

+        return this.fSchemaContent;

     }

     

-    public void setContent(Object schemaContent)

-    {

-        this.fContent = schemaContent;

-    }

-    

-    public Object getContent()

-    {

-        return this.fContent;

-    }

-

 }


Modified: 
incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImportImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImportImpl.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- 
incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImportImpl.java 
(original)
+++ 
incubator/woden/java/src/org/apache/woden/internal/schema/SchemaImportImpl.java 
Wed Sep 14 03:21:32 2005
@@ -3,10 +3,12 @@
  */

 package org.apache.woden.internal.schema;

 

+import org.apache.woden.schema.Schema;

 import org.apache.woden.schema.SchemaImport;

 

 /**

- * A wrapper for a schema import element.

+ * Represents a schema import element such as &lt;xs:import&gt; and

+ * provides a reference to the imported <code>Schema</code> object.

  * 

  * @author [EMAIL PROTECTED]

  */

@@ -14,8 +16,7 @@
     

     private String fNamespace = null;

     private String fSchemaLocation = null;

-    private String fContentModel;

-    private Object fContent;

+    private Schema fSchema;

 

     /* (non-Javadoc)

      * @see 
org.apache.woden.wsdl20.extensions.SchemaImport#setNamespace(java.lang.String)

@@ -50,23 +51,14 @@
         return this.fSchemaLocation;

     }

     

-    public void setContentModel(String contentModel)

+    public void setSchema(Schema schema)

     {

-        this.fContentModel = contentModel;

+        this.fSchema = schema;

     }

     

-    public String getContentModel()

+    public Schema getSchema()

     {

-        return this.fContentModel;

+        return this.fSchema;

     }

 

-    public void setContent(Object importedSchemaContent)

-    {

-        this.fContent = importedSchemaContent;

-    }

-    

-    public Object getContent()

-    {

-        return this.fContent;

-    }

 }


Modified: 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/Constants.java 
Wed Sep 14 03:21:32 2005
@@ -3,6 +3,7 @@
  */

 

 //TODO - consider separating common constants from 2.0 constants

+//TODO - check if any constants copied from w4j can be deleted

 

 

 package org.apache.woden.internal.wsdl20;

@@ -89,6 +90,7 @@
     

     

     // Attribute names.

+    public static final String ATTR_ID = "id";

     public static final String ATTR_NAME = "name";

     public static final String ATTR_TARGET_NAMESPACE = "targetNamespace";

     public static final String ATTR_EXTENDS = "extends";

@@ -104,15 +106,6 @@
     public static final String ATTR_BINDING = "binding";

     public static final String ATTR_LOCATION = "address";

   

-    //Type system or content model (API) used for the types

-    public static final String TYPE_XSD_2001 =

-        "http://www.w3.org/2001/XMLSchema";;

-    public static final String TYPE_DOM_API =

-        "org.w3c.dom";

-    public static final String TYPE_XS_API =

-        "org.apache.xerces.xs";              //XML Schema API

-    

-    

   //TODO determine if/how these needed

   public static final String ATTR_XMLNS = "xmlns";

   public static final String ATTR_NAMESPACE = "namespace";


Modified: incubator/woden/java/src/org/apache/woden/schema/Schema.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/schema/Schema.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/schema/Schema.java (original)
+++ incubator/woden/java/src/org/apache/woden/schema/Schema.java Wed Sep 14 
03:21:32 2005
@@ -3,25 +3,20 @@
  */

 package org.apache.woden.schema;

 

+import org.apache.axis.xsd.xml.schema.*;  //TODO test ws-commons XmlSchema

+

 /**

- * This interface represents the root schema element from any XML based 

- * type system that supports the semantics of schema inlining and 

- * schema importing. For example, in the W3C XML Schema type system 

- * is represents the &lt;xs:schema&gt; element. For Relax NG, it

- * represents the &lt;rng:grammar&gt; element.

+ * This interface represents the a schema element from any XML based 

+ * schema type system that supports schema inlining and importing. 

+ * For example, in the W3C XML Schema type system it represents the 

+ * &lt;xs:schema&gt; element. For Relax NG, it represents the 

+ * &lt;rng:grammar&gt; element.

  * <p>

- * A schema element may be parsed with various APIs and represent with 

- * different schema object models. This interface acts as a wrapper for

- * the schema element. It exposes just the required targetNamespace attribute

- * and the id attribute, which is optional. The id attribute may be used to

- * distinguish multiple schemas with the same targetNamespace. 

- * The schema element is wrapped as a java.lang.Object and  

- * a content model indicator identifies which object model or API has been 

- * used to represent the schema in memory. A client application needing to 

- * process the underlying schema components can use this indicator to cast 

- * the schema Object to the appropriate type. For example, if it indicates 

- * that the DOM API has been used to represent the Schema, then the schema 

- * Object should be cast to an org.w3c.dom.Element.

+ * This interface exposes the id and target namespace attributes of the

+ * schema element. The id attribute may be used to distinguish multiple 

+ * schemas with the same targetNamespace (e.g. multiple schemas defining

+ * different elements and types from the same namespace). The actual 

+ * schema content is represented as an <code>XmlSchema</code> object.

  * <p>

  * NOTE: non-XML type systems like DTD are not handled by this interface. They 
must be

  * handled by WSDL 2.0 extension mechanisms.

@@ -34,16 +29,16 @@
  */

 public interface Schema {

 

-    public void setTargetNamespace(String namespace);

-    

-    public String getTargetNamespace();

-    

     public void setId(String id);

     

     public String getId();

     

-    public String getContentModel();

+    public void setTargetNamespace(String namespace);

+    

+    public String getTargetNamespace();

+    

+    public void setSchemaContent(XmlSchema xmlSchema);

     

-    public Object getContent();

+    public XmlSchema getSchemaContent();

     

 }


Modified: incubator/woden/java/src/org/apache/woden/schema/SchemaImport.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/schema/SchemaImport.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/schema/SchemaImport.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/schema/SchemaImport.java Wed Sep 
14 03:21:32 2005
@@ -4,23 +4,16 @@
 package org.apache.woden.schema;

 

 /**

- * This interface represents a schema import element from any XML based 

- * type system that supports the semantics of schema inlining and 

- * schema importing. For example, in the W3C XML Schema type system 

- * it represents the &lt;xs:import&gt; element. For Relax NG, it

- * represents the &lt;rng:include&gt; element.

+ * This interface represents the import element from any XML based 

+ * schema type system that supports schema inlining and importing. 

+ * For example, in the W3C XML Schema type system it represents the 

+ * &lt;xs:import&gt; element. For Relax NG, it represents the 

+ * &lt;rng:include&gt; element.

  * <p>

- * The interface exposes the required namespace attribute and the 

- * optional schemaLocation attribute. The schemaLocation may be used

- * to distinguish multiple schema import elements with the same 

- * namespace.  The imported schema is wrapped as a java.lang.Object 

- * and a content model indicator identifies which object model or API

- * has been used to represent the schema in memory. A client application

- * needing to process the underlying schema components can use this 

- * indicator to cast the imported schema Object to the appropriate type. 

- * For example, if it indicates that the DOM API has been used for the 

- * schema content, then the imported schema Object should be cast to an 

- * org.w3c.dom.Element.

+ * The interface exposes the import namespace and schemaLocation. 

+ * The schemaLocation may be used to distinguish multiple schema imports 

+ * from the same namespace. The interface also refers to a <code>Schema</code>

+ * representing the imported schema.

  * <p>

  * NOTE: non-XML type systems like DTD are not handled by this interface. They 
must be

  * handled by WSDL 2.0 extension mechanisms.

@@ -41,7 +34,7 @@
     

     public String getSchemaLocation();

 

-    public String getContentModel();

+    public void setSchema(Schema importedSchema);

     

-    public Object getContent();

+    public Schema getSchema();

 }


Modified: incubator/woden/java/src/org/apache/woden/wsdl20/xml/TypesElement.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/xml/TypesElement.java?rev=280813&r1=280812&r2=280813&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/xml/TypesElement.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/xml/TypesElement.java Wed 
Sep 14 03:21:32 2005
@@ -8,35 +8,38 @@
 import org.apache.woden.schema.Schema;

 import org.apache.woden.schema.SchemaImport;

 

-

 /**

- * This interface represents the XML element information item for

- * a WSDL 2.0 &lt;types&gt; element. It declares the behaviour required to 

- * support parsing, creating and manipulating a &lt;types&gt; element.

+ * This interface represents the &lt;wsdl:types&gt; element. 

+ * It supports parsing, creating and manipulating a &lt;types&gt; element.

  * <p>

- * Note that it is valid for a &lt;types&gt; element to have multiple 

- * imported schemas with the same namespace, so the schemaLocation 

- * attribute may be used to distinguish them.

- * Likewise, it is valid to have multiple inline schemas (providing no 

- * schema elements or types share the same names), so the id attribute 

+ * The data types used in WSDL elements are typically defined within a 

+ * &lt;types&gt; element using a type system such as W3C XML Schema.

+ * Schemas may be imported or inlined within &lt;types&gt;.

+ * A &lt;types&gt; element may contain multiple schema import elements with

+ * the same namespace attribute, so the schemaLocation attribute may be used 

+ * to distinguish them.

+ * Likewise, it is valid to have multiple inline schemas, so the id attribute 

  * may be used to distinguish them.

  * 

- * TODO Initial type system support is specific to XML Schema. 

- *      Need generic support for other type systems.

- * 

  * @author [EMAIL PROTECTED]

  */

 public interface TypesElement extends WSDL20Element {

     

+    //TODO consider where in the API to query or set the type system used.

+    

+    //Constant to indicate type system used is W3C XML Schema.

+    public static final String TYPESYSTEM_XSD_2001 = 

+        "http://www.w3.org/2001/XMLSchema";;

+    

     public void setDocumentationElement(DocumentationElement docEl);

     

     public DocumentationElement getDocumentationElement();

     

     /**

-     * Indicate the type system used within the &lt;types&gt; 

-     * element. Typically the XML Schema type system will be 

-     * used, represented by the XML Schema namespace 

-     * "http://www.w3.org/2001/XMLSchema";.

+     * Indicates the type system used within the &lt;types&gt; element. 

+     * Typically the W3C XML Schema type system will be used, indicated by 

+     * the namespace "http://www.w3.org/2001/XMLSchema";. An alternative

+     * schema-like type system is Relax NG (http://www.relaxng.org/).

      */

     public void setTypeSystem(String typeSystem);

     

@@ -49,11 +52,11 @@
     /*

      * Schema imports &lt;xs:import&gt; are stored in a Map of SchemaImport[] 

      * keyed by namespace. The schemaLocation attribute will distinguish

-     * schemas imported with the same namespace.

+     * schemas imported from the same namespace.

      */

 

     /**

-     * Add a SchemaImport to the schemas imported within the &lt;types&gt; 
element.

+     * Add to the collection of schemas imported within the &lt;types&gt; 
element.

      */

     public void addSchemaImport(SchemaImport schemaImport);

     

@@ -95,7 +98,7 @@
      */

     

     /**

-     * Add a Schema to the schemas defined inline within the &lt;types&gt; 
element.

+     * Add add to the collection of schemas inlined within the &lt;types&gt; 
element.

      */

     public void addSchema(Schema schema);

     




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

Reply via email to