You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by sa...@apache.org on 2009/09/01 07:56:02 UTC

svn commit: r809837 - in /webservices/woden/trunk/java/woden-om: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/woden/ src/main/java/org/apache/woden/internal/ src/main/java/org/apache/woden/inter...

Author: sagara
Date: Tue Sep  1 05:56:01 2009
New Revision: 809837

URL: http://svn.apache.org/viewvc?rev=809837&view=rev
Log:
Merging Woden-211 branch as the trunk.

Added:
    webservices/woden/trunk/java/woden-om/src/
    webservices/woden/trunk/java/woden-om/src/main/
    webservices/woden/trunk/java/woden-om/src/main/java/
    webservices/woden/trunk/java/woden-om/src/main/java/org/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLFactory.java
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLReader.java
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMXMLElement.java
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMQNameUtils.java
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMUtils.java
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/xpointer/
    webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/xpointer/OMXMLElementEvaluator.java
    webservices/woden/trunk/java/woden-om/src/test/
    webservices/woden/trunk/java/woden-om/src/test/java/
    webservices/woden/trunk/java/woden-om/src/test/java/org/
    webservices/woden/trunk/java/woden-om/src/test/java/org/apache/
    webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/
    webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java
    webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMXMLElementTest.java
Modified:
    webservices/woden/trunk/java/woden-om/pom.xml

Modified: webservices/woden/trunk/java/woden-om/pom.xml
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/pom.xml?rev=809837&r1=809836&r2=809837&view=diff
==============================================================================
--- webservices/woden/trunk/java/woden-om/pom.xml (original)
+++ webservices/woden/trunk/java/woden-om/pom.xml Tue Sep  1 05:56:01 2009
@@ -29,23 +29,9 @@
    <artifactId>woden-impl-om</artifactId>
    <name>Woden - OM</name>
    <build>
-       <sourceDirectory>../src</sourceDirectory>
-       <testSourceDirectory>../test</testSourceDirectory>
        <resources>
            <resource>
-               <directory>../src</directory>
-               <includes>
-                   <include>**/internal/**</include>
-                   <include>**/javax/xml/namespace/**</include>
-                   <include>**/tool/converter/**</include>
-               </includes>
-               <excludes>
-                   <exclude>**/internal/DOM**</exclude>
-                   <exclude>**/internal/resolver/DOM**</exclude>
-                   <exclude>**/internal/util/dom/**</exclude>
-                   <exclude>**/internal/xpointer/DOM**</exclude>
-                   <exclude>**/*.java</exclude>
-               </excludes>
+               <directory>src/main/resources</directory>
            </resource>
            <resource>
                <targetPath>META-INF</targetPath>
@@ -57,42 +43,14 @@
                </includes>
            </resource>
        </resources>
-       <testResources>
-           <testResource>
-               <directory>../test</directory>
-               <excludes>
-                   <exclude>**/*.java</exclude>
-               </excludes>
-           </testResource>
-       </testResources>
 
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
-                   <includes>
-                       <include>**/internal/**</include>
-                       <include>**/javax/xml/namespace/**</include>
-                       <include>**/tool/converter/**</include>
-                   </includes>
-                   <excludes>
-                       <exclude>**/internal/DOM**</exclude>
-                       <exclude>**/internal/resolver/DOM**</exclude>
-                       <exclude>**/internal/util/dom/**</exclude>
-                       <exclude>**/internal/xpointer/DOM**</exclude>
-                   </excludes>
                    <source>1.4</source>
                    <target>1.4</target>
                    <compilerArgument>-g</compilerArgument>
-                   <testExcludes>
-                       <exclude>**/ant/*</exclude>
-                       <exclude>**/DOM*</exclude>
-                       <exclude>**/AllWodenTests.java</exclude>
-                       <exclude>**/AllWodenTestsDOM.java</exclude>
-                       <exclude>**/SchemaTest.java</exclude>
-                       <exclude>**/SchemaLocationTest.java</exclude>
-                       <exclude>**/WSDLDocumentValidatorTest.java</exclude>
-                   </testExcludes>
                </configuration>
            </plugin>
            <plugin>
@@ -125,8 +83,18 @@
    <dependencies>
        <dependency>
            <groupId>org.apache.woden</groupId>
-           <artifactId>woden-api</artifactId>
+           <artifactId>woden-impl-commons</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
+     <!-- This dependency is need for getting shared test resources.
+          See http://tildemh.com/2007/12/19/maven2-unit-test-dependencies
+      -->
+     <dependency>
+       <groupId>org.apache.woden</groupId>
+       <artifactId>woden-impl-commons</artifactId>
+       <version>1.0-SNAPSHOT</version>
+       <scope>test</scope>
+       <classifier>tests</classifier>
+     </dependency>
    </dependencies>
 </project>
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLFactory.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLFactory.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLFactory.java (added)
+++ webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLFactory.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.internal;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLReader;
+
+public class OMWSDLFactory extends BaseWSDLFactory {
+
+    public OMWSDLFactory() throws WSDLException {
+        super();
+    }
+    
+    //Returns an OMWSDLReader
+    public WSDLReader newWSDLReader() throws WSDLException {
+        return new OMWSDLReader(fWsdlContext);
+    }
+
+}

Added: webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLReader.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLReader.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLReader.java (added)
+++ webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMWSDLReader.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,546 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLSource;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.resolver.OMSchemaResolverAdapter;
+import org.apache.woden.internal.schema.ImportedSchemaImpl;
+import org.apache.woden.internal.schema.InlinedSchemaImpl;
+import org.apache.woden.internal.schema.SchemaConstants;
+import org.apache.woden.internal.util.StringUtils;
+import org.apache.woden.internal.util.om.OMQNameUtils;
+import org.apache.woden.internal.util.om.OMUtils;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.internal.xpointer.OMXMLElementEvaluator;
+import org.apache.woden.schema.Schema;
+import org.apache.woden.types.NamespaceDeclaration;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.WSDLElement;
+import org.apache.woden.xpointer.InvalidXPointerException;
+import org.apache.woden.xpointer.XPointer;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.apache.ws.commons.schema.XmlSchemaException;
+import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.xml.sax.InputSource;
+
+/**
+ * Implements WSDL reader behaviour for OM based parsing
+ */
+public class OMWSDLReader extends BaseWSDLReader{
+
+    //A map of imported schema definitions keyed by schema location URI
+    private Map fImportedSchemas = new Hashtable();
+
+    OMWSDLReader(WSDLContext wsdlContext) throws WSDLException {
+        super(wsdlContext);
+    }
+
+    public Description readWSDL(String wsdlURI) throws WSDLException {
+        //This conversion to a URL is necessary to import the schema
+        URL url;
+        try {
+            url = StringUtils.getURL(null, wsdlURI);
+        } catch (MalformedURLException e) {
+            String msg = getErrorReporter().getFormattedMessage(
+                            "WSDL502", new Object[] {null, wsdlURI});
+            throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+        }
+        String wsdlURL = url.toString();
+
+        OMElement root = null;
+
+        // perform URI Resolution here
+        try {
+            root = OMUtils.getElement(resolveURI(wsdlURL));
+        } catch (IOException e){
+            String msg = getErrorReporter().getFormattedMessage(
+                    "WSDL503", new Object[] {wsdlURI});
+            throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+        } catch (URISyntaxException e){
+            String msg = getErrorReporter().getFormattedMessage(
+                    "WSDL502", new Object[] {null, wsdlURI});
+            throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+        } catch (XMLStreamException e){
+            String msg = getErrorReporter().getFormattedMessage(
+                    "WSDL500", new Object[] {"XML", wsdlURI});
+            throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+        }
+        //Try to find an element the XPointer points to if a Fragment Identifier exists.
+        URI uri = null;
+        try {
+            uri = new URI(wsdlURI);
+        } catch (URISyntaxException e) {
+            String msg = getErrorReporter().getFormattedMessage(
+                    "WSDL506", new Object[] {wsdlURI});
+            throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+        }
+        
+        String fragment = uri.getFragment();
+
+        if (fragment == null) { //No fragment identifier so just use the root element.
+            XMLElement descEl = createXMLElement(root);
+            DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
+            return descElem.toComponent();
+        } else {
+            XPointer xpointer;
+            try {
+                xpointer = new XPointer(fragment);
+            } catch(InvalidXPointerException e) {
+                String msg = getErrorReporter().getFormattedMessage(
+                        "WSDL530", new Object[] {fragment, wsdlURI});
+                throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+            }
+            
+            OMXMLElementEvaluator evaluator = new OMXMLElementEvaluator(xpointer, root, getErrorReporter());
+            OMElement result = evaluator.evaluateElement();
+            
+            if (result != null) { //Element from XPointer evaluation.
+                XMLElement descEl = createXMLElement(result);
+                DescriptionElement descElem = parseDescription(url.toString(), descEl, null);
+                return descElem.toComponent();
+            } else {
+                String msg = getErrorReporter().getFormattedMessage(
+                        "WSDL531", new Object[] {fragment, wsdlURI});
+                throw new WSDLException(WSDLException.PARSER_ERROR, msg);
+            }
+        }
+    }
+
+    /*
+     * Parse the &lt;xs:import&gt; element and retrieve the imported
+     * schema document if schemaLocation specified. Failure to retrieve
+     * the schema will only matter if any WSDL components contain elements or
+     * constraints that refer to the schema, and typically this will be
+     * determined later by WSDL validation. So just report any such errors
+     * and return the SchemaImport object (i.e. with a null schema property).
+     *
+     * WSDL 2.0 spec validation:
+     * - namespace attribute is REQUIRED
+     * - imported schema MUST have a targetNamespace
+     * - namespace and targetNamespace MUST be the same
+     */
+    protected Schema parseSchemaImport(XMLElement importEl,
+                                     DescriptionElement desc)
+                                     throws WSDLException {
+
+        ImportedSchemaImpl schema = new ImportedSchemaImpl();
+
+        String ns = importEl.getAttributeValue(SchemaConstants.ATTR_NAMESPACE);
+
+        if(ns != null) {
+            schema.setNamespace(getURI(ns));
+        }
+
+        String sloc = importEl.getAttributeValue(SchemaConstants.ATTR_SCHEMA_LOCATION);
+        if(sloc != null) {
+            schema.setSchemaLocation(getURI(sloc));
+        }
+
+        if(schema.getNamespace() == null){
+            //The namespace attribute is REQUIRED on xs:import, so don't continue.
+            schema.setReferenceable(false);
+            return schema;
+        }
+
+        if(schema.getSchemaLocation() == null){
+            //This is a namespace-only import, no schema document to be retrieved so don't continue.
+
+            /* TODO investigate whether/how to try to resolve the imported namespace to known schema
+             * components from that namespace (e.g. via a URI catalog resolver). Currently, any attempt
+             * to resolve a QName against schema components from this namespace will search ALL
+             * schemas imported from this namespace (see methods in TypesImpl).
+             */
+
+            return schema;
+        }
+
+        //Now try to retrieve the schema import using schemaLocation
+
+        OMElement importedSchemaDoc = null;
+        URI contextURI = null;
+        String schemaLoc = null;
+        URL url = null;
+
+        try{
+        	/*
+        	 * For simple resolvers, we resolve the parent (Description) URI
+        	 * to be used as the context. This allows for relative locationURIs
+        	 * to be resolved implicitly - they are considered to be located 
+        	 * relative to the resolved parent. Therefore, relative URIs such as these
+        	 * need not be listed in the catalog file.
+        	 */
+        	
+        	/* TODO
+        	 * OASIS-style catalogs have a convenience notation to define root URIs
+        	 * thus grouping related URLs together. In this case the context URI here
+        	 * should be left alone, but the resultant locationURL resolved instead.
+        	 * 
+        	 * Implement a boolean system property like org.apache.woden.resolver.useRelativeURLs
+        	 * (set by the resolver ctor). SimpleURIResolver (et al) should set this to true,
+        	 * OASISCatalogResolver should set to false. 
+        	 */
+        	// contextURI = desc.getDocumentBaseURI();
+        	contextURI = resolveURI(desc.getDocumentBaseURI());
+            URL contextURL = (contextURI != null) ? contextURI.toURL() : null;
+            schemaLoc = schema.getSchemaLocation().toString();
+            url = StringUtils.getURL(contextURL, schemaLoc);
+
+        }
+        catch (MalformedURLException e) {
+
+            String baseLoc = contextURI != null ? contextURI.toString() : null;
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL502",
+                    new Object[] {baseLoc, schemaLoc},
+                    ErrorReporter.SEVERITY_ERROR);
+
+            //can't continue schema retrieval with a bad URL.
+            schema.setReferenceable(false);
+            return schema;
+        }
+
+        String schemaURL = url.toString();
+
+        //If the schema has already been imported, reuse it.
+        XmlSchema schemaDef = (XmlSchema)fImportedSchemas.get(schemaURL);
+
+        if(schemaDef == null){
+            //not previously imported, so retrieve it now.
+            try {
+                importedSchemaDoc = OMUtils.getElement(schemaURL);
+            } catch (URISyntaxException e){
+                String msg = getErrorReporter().getFormattedMessage(
+                        "WSDL502", new Object[] {null, schemaURL});
+                throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+            } catch (XMLStreamException e){
+                String msg = getErrorReporter().getFormattedMessage(
+                        "WSDL500", new Object[] {"XML", schemaURL});
+                throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+            } catch (IOException e4) {
+                
+                //schema retrieval failed (e.g. 'not found')
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  //TODO line&col nos.
+                        "WSDL504", 
+                        new Object[] {schemaURL}, 
+                        ErrorReporter.SEVERITY_WARNING, 
+                        e4);
+                
+                //cannot continue without an imported schema
+                schema.setReferenceable(false);
+                return schema;
+            }
+
+            /*
+            * First get the schema element and serialize that into a byte array.
+            * This is used in getting an InputSource which is later used as an argument
+            * to the XMLSchemaCollection object.
+            */
+            String schemaElStr = null;
+            try {
+                schemaElStr = importedSchemaDoc.toStringWithConsume();
+            }
+            catch (XMLStreamException e) {
+                e.printStackTrace();
+            }
+            byte[] schemaElbytes = schemaElStr.getBytes();
+            InputSource schemaSource = new InputSource(new ByteArrayInputStream(schemaElbytes));
+            schemaSource.setSystemId(schemaURL);
+
+            try {
+                XmlSchemaCollection xsc = new XmlSchemaCollection();
+                
+                // Plug in the selected woden URI Resolver
+                xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), importEl));
+                
+                schemaDef = xsc.read(schemaSource, null);
+                fImportedSchemas.put(schemaURL, schemaDef);
+            }
+            catch (XmlSchemaException e){
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  //TODO line&col nos.
+                        "WSDL522",
+                        new Object[] {schemaURL},
+                        ErrorReporter.SEVERITY_WARNING,
+                        e);
+            }
+        }
+        if(schemaDef != null) {
+            schema.setSchemaDefinition(schemaDef);
+        }
+        else {
+            schema.setReferenceable(false);
+        }
+        return schema;
+    }
+
+
+    protected Schema parseSchemaInline(XMLElement schemaElement,
+                                     DescriptionElement desc)
+                                     throws WSDLException{
+
+        InlinedSchemaImpl schema = new InlinedSchemaImpl();
+        schema.setId(schemaElement.getAttributeValue(SchemaConstants.ATTR_ID));
+        String tns = schemaElement.getAttributeValue(SchemaConstants.ATTR_TARGET_NAMESPACE);
+        if(tns != null) {
+            schema.setNamespace(getURI(tns));
+        }
+
+        String baseURI = desc.getDocumentBaseURI() != null ?
+                         desc.getDocumentBaseURI().toString() : null;
+
+        XmlSchema schemaDef = null;
+
+        try {
+            OMElement omSchemaElem = (OMElement)schemaElement.getSource();
+            InputSource schemaSource = OMUtils.getInputSource(omSchemaElem);
+            XmlSchemaCollection xsc = new XmlSchemaCollection();
+
+            //Set the baseURI and the namespaces from the DescriptionElement in the XMLSchemaCollection
+            xsc.setBaseUri(baseURI);
+            
+            NamespaceMap namespaces = new NamespaceMap();
+            Iterator it = Arrays.asList(desc.getDeclaredNamespaces()).iterator();
+            while(it.hasNext()) {
+                NamespaceDeclaration d = (NamespaceDeclaration)it.next();
+                namespaces.add(d.getPrefix(), d.getNamespaceURI().toString());
+            }
+            xsc.setNamespaceContext(namespaces);
+            
+            // Plug in the selected woden URI Resolver
+            xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), schemaElement));
+            
+            schemaDef = xsc.read(schemaSource, null);
+        }
+        catch (XmlSchemaException e){
+
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL521",
+                    new Object[] {baseURI},
+                    ErrorReporter.SEVERITY_WARNING,
+                    e);
+        }
+        catch (RuntimeException e)
+        {
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL521", 
+                    new Object[] {baseURI}, 
+                    ErrorReporter.SEVERITY_ERROR,
+                    e);            
+        }
+        
+        if(schemaDef != null) {
+            schema.setSchemaDefinition(schemaDef);
+        }
+        else {
+            schema.setReferenceable(false);
+        }
+
+        return schema;
+    }
+    
+
+    //TODO
+    protected void parseExtensionAttributes(XMLElement domEl,
+                                          Class wsdlClass,
+                                          WSDLElement wsdlObj,
+                                          DescriptionElement desc)
+                                          throws WSDLException {
+    }
+
+    ///////////////////////////////////////
+    //  METHODS FOR READING FROM A SOURCE
+    ///////////////////////////////////////
+
+    //TODO
+    public Description readWSDL(WSDLSource wsdlSource)
+                                    throws WSDLException {
+        return null;
+    }
+
+    //////////////////////////
+    //  HELPER METHODS
+    //////////////////////////
+
+
+    /*
+     * Retrieve a WSDL document by resolving the location URI specified
+     * on a WSDL &lt;import&gt; or &lt;include&gt; element.
+     *
+     * TODO add support for a URL Catalog Resolver
+     */
+    protected DescriptionElement getWSDLFromLocation(String locationURI,
+                                                   DescriptionElement desc,
+                                                   Map wsdlModules)
+                                               throws WSDLException{
+        DescriptionElement referencedDesc = null;
+        OMElement docEl;
+        URL locationURL = null;
+        URI contextURI = null;
+
+        try{
+        	/*
+        	 * For simple resolvers, we resolve the parent (Description) URI
+        	 * to be used as the context. This allows for relative locationURIs
+        	 * to be resolved implicitly - they are considered to be located 
+        	 * relative to the resolved parent. Therefore, relative URIs such as these
+        	 * need not be listed in the catalog file.
+        	 */
+        	
+        	/* TODO
+        	 * OASIS-style catalogs have a convenience notation to define root URIs
+        	 * thus grouping related URLs together. In this case the context URI here
+        	 * should be left alone, but the resultant locationURL resolved instead.
+        	 * 
+        	 * Implement a boolean system property like org.apache.woden.resolver.useRelativeURLs
+        	 * (set by the resolver ctor). SimpleURIResolver (et al) should set this to true,
+        	 * OASISCatalogResolver should set to false. 
+        	 */
+        	// contextURI = desc.getDocumentBaseURI();
+        	contextURI = resolveURI(desc.getDocumentBaseURI());
+            URL contextURL = (contextURI != null) ? contextURI.toURL() : null;
+            locationURL = StringUtils.getURL(contextURL, locationURI);
+        }
+        catch (MalformedURLException e){
+            String baseURI = contextURI != null ? contextURI.toString() : null;
+
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL502",
+                    new Object[] {baseURI, locationURI},
+                    ErrorReporter.SEVERITY_ERROR);
+
+            //can't continue import with a bad URL.
+            return null;
+        }
+
+        String locationStr = locationURL.toString();
+
+        //Check if WSDL imported or included previously from this location.
+        referencedDesc = (DescriptionElement)wsdlModules.get(locationStr);
+
+        if(referencedDesc == null){
+            // not previously imported or included, so retrieve the WSDL.
+            try {
+                docEl = OMUtils.getElement(locationStr);
+            } catch (URISyntaxException e){
+                String msg = getErrorReporter().getFormattedMessage(
+                        "WSDL502", new Object[] {null, locationStr});
+                throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+            } catch (XMLStreamException e){
+                String msg = getErrorReporter().getFormattedMessage(
+                        "WSDL500", new Object[] {"XML", locationStr});
+                throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+            } catch (IOException e) {
+                // document retrieval failed (e.g. 'not found')
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  // TODO line&col nos.
+                        "WSDL503", 
+                        new Object[] {locationStr}, 
+                        ErrorReporter.SEVERITY_WARNING, 
+                        e);
+                
+                // cannot continue without the referenced document
+                return null;
+            }
+
+            //The referenced document should contain a WSDL <description>
+            if(!OMQNameUtils.matches(Constants.Q_ELEM_DESCRIPTION, docEl)){
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  //TODO line&col nos.
+                        "WSDL501",
+                        new Object[] {Constants.Q_ELEM_DESCRIPTION,
+                                      OMQNameUtils.newQName(docEl)},
+                        ErrorReporter.SEVERITY_ERROR);
+
+                //cannot continue without a <description> element
+                return null;
+            }
+
+            XMLElement descEl = createXMLElement(docEl);
+            
+            referencedDesc = parseDescription(locationStr,
+                                              descEl,
+                                              wsdlModules);
+
+            if(!wsdlModules.containsKey(locationStr)){
+                wsdlModules.put(locationStr, referencedDesc);
+            }
+        }
+
+        return referencedDesc;
+    }
+
+    //TODO
+    public WSDLSource createWSDLSource() {
+        return null;
+    }
+
+    protected XMLElement createXMLElement(Object elem) {
+        OMXMLElement omXMLElement =  new OMXMLElement(getErrorReporter());
+        omXMLElement.setSource(elem);
+        return omXMLElement;
+
+    }
+
+    protected void parseNamespaceDeclarations(
+            XMLElement xmlElem, 
+            WSDLElement wsdlElem) 
+            throws WSDLException {
+        OMElement omDescription = (OMElement)xmlElem.getSource();
+        
+        Iterator namespaces = omDescription.getAllDeclaredNamespaces();
+        while(namespaces.hasNext()){
+            OMNamespace namespace = (OMNamespace)namespaces.next();
+            String localPart = namespace.getPrefix();
+            String value = namespace.getNamespaceURI();
+
+          if (!(Constants.ATTR_XMLNS).equals(localPart)){
+            wsdlElem.addNamespace(localPart, getURI(value));  //a prefixed namespace
+          }
+          else{
+            wsdlElem.addNamespace(null, getURI(value));       //the default namespace
+          }
+        }
+    }
+
+}
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMXMLElement.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMXMLElement.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMXMLElement.java (added)
+++ webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/OMXMLElement.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,171 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.woden.internal;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+
+public class OMXMLElement extends BaseXMLElement{
+
+    private static final String emptyString = "".intern();
+    
+    public OMXMLElement(ErrorReporter errorReporter) {
+        super(errorReporter);
+    }
+
+    /*
+     * @see org.apache.woden.XMLElement#setSource(java.lang.Object)
+     */
+    public void setSource(Object elem) {
+
+        if(elem instanceof OMElement) {
+            fSource = elem;
+        }
+        else {
+            String elemClass = (elem != null
+                                     ? elem.getClass().getName()
+                                     : null);
+            String xmlElementClass = this.getClass().getName();
+            String msg = fErrorReporter.getFormattedMessage(
+                    "WSDL019", new Object[] {elemClass, xmlElementClass});
+            throw new IllegalArgumentException(msg);
+        }
+
+    }
+
+    /*TODO complete this method if it's added to XMLElement.
+     *
+    public XMLAttribute[] getAttributes() {
+
+        if (fSource instanceof OMElement){
+            OMElement elem = (OMElement)fSource;
+            List attrs = new Vector();
+            Iterator iter =  elem.getAllAttributes();
+            while (iter.hasNext()){
+                //No need to check for xmlns, since AXIOM knows that if it's prefixed
+                // with xmlns, that it's not an attribute
+                //TODO create an XMLAttribute from iter.next()
+                //attrs.add(xmlAttribute);
+            }
+        }
+
+        XMLElement[] array = new XMLElement[attrs.size()];
+        attrs.toArray(array);
+        return array;
+    }
+     */
+
+    protected String doGetAttributeValue(String attrName) {
+        OMElement elem = (OMElement)fSource;
+        return elem.getAttributeValue(new QName(attrName));
+    }
+
+    protected URI doGetNamespaceURI() throws WSDLException {
+        OMElement elem = (OMElement)fSource;
+        String nsStr =  elem.getNamespace().getNamespaceURI();
+        URI uri = null;
+        if (nsStr != null) {
+            try {
+                uri = new URI(nsStr);
+            } catch (URISyntaxException e) {
+                String msg = fErrorReporter.getFormattedMessage("WSDL506", new Object[] { nsStr });
+                throw new WSDLException(WSDLException.INVALID_WSDL, msg, e);
+            }
+        }
+        return uri;
+    }
+
+    protected String doGetLocalName() {
+        OMElement elem = (OMElement)fSource;
+        return elem.getLocalName();
+    }
+    
+    protected QName doGetQName() {
+        OMElement elem = (OMElement)fSource;
+        return elem.getQName();
+    }
+
+    protected QName doGetQName(String prefixedValue) throws WSDLException {
+        OMElement elem = (OMElement)fSource;
+        int index = prefixedValue.indexOf(':');
+        String prefix = (index != -1)
+                        ? prefixedValue.substring(0, index)
+                        : null;
+        String localPart    = prefixedValue.substring(index + 1);
+        OMNamespace OMns    = elem.findNamespaceURI(prefix);
+        String namespaceURI = OMns != null ? OMns.getNamespaceURI() : null;
+
+        if(prefix != null && namespaceURI == null) {
+            String faultCode = WSDLException.UNBOUND_PREFIX;
+            String msg = fErrorReporter.getFormattedMessage(
+                    "WSDL513", 
+                    new Object[] {prefixedValue, elem.getQName()});
+            WSDLException wsdlExc = new WSDLException(
+                    faultCode,
+                    msg);
+            //TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
+            throw wsdlExc;
+        }
+        
+        return new QName(namespaceURI, localPart, (prefix != null ? prefix : emptyString));
+    }
+
+    protected XMLElement doGetFirstChildElement() {
+        OMElement elem = (OMElement)fSource;
+        OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+        omXMLElement.setSource(elem.getFirstElement());
+        return omXMLElement;
+    }
+
+    protected XMLElement doGetNextSiblingElement() {
+        OMElement elem = (OMElement)fSource;
+        OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+        omXMLElement.setSource(elem.getNextOMSibling());
+        return omXMLElement;
+    }
+        
+    protected XMLElement[] doGetChildElements() {
+        
+        OMElement elem = (OMElement)fSource;
+        Iterator elems = elem.getChildElements();
+        List children = new Vector();
+        Object next = elems.next();
+        while(next != null)
+        {
+            OMXMLElement omXMLElement = new OMXMLElement(fErrorReporter);
+            omXMLElement.setSource(next);
+            children.add(omXMLElement);
+            next = elems.next();
+        }
+        XMLElement[] array = new XMLElement[children.size()];
+        children.toArray(array);
+        return array;
+    }
+    
+}

Added: webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMQNameUtils.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMQNameUtils.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMQNameUtils.java (added)
+++ webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMQNameUtils.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.internal.util.om;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Class to handle some trivial functionality related to QNames.
+ */
+public class OMQNameUtils {
+
+    /**
+     * @param qname The relevant QName to be matched
+     * @param element
+     * @return true if the given QName matches the element's and false otherwise
+     */
+    public static boolean matches(QName qname, OMElement element){
+      return (element != null && qname.equals(newQName(element)));
+    }
+
+    /* TODO: this method could be unnecessary!
+     * @param element
+     * @return a QName based on the OMElement
+     */
+    public static QName newQName(OMElement element){
+      if (element != null){
+        OMNamespace namespace = element.getNamespace();
+        return new QName(namespace.getNamespaceURI(), element.getLocalName());
+      }
+      else{
+        return null;
+      }
+    }
+}
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMUtils.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMUtils.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMUtils.java (added)
+++ webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/util/om/OMUtils.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,111 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.internal.util.om;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.xml.sax.InputSource;
+
+/**
+ * This class contains utility methods required for parsing elements
+ * in a WSDL using AXIOM.
+ */
+public class OMUtils {
+
+    /**
+     * @param strUri The URI where the WSDL can be found
+     * @return A StAXOMBuilder which could be used in obtaining the document object
+     * @throws IOException 
+     */
+    public static StAXOMBuilder getOMBuilder(String strUri) throws IOException, URISyntaxException, XMLStreamException  {
+        StAXOMBuilder builder = null;
+        
+        URI uri = new URI(strUri);
+        URL url = uri.toURL();
+        
+        InputStream in = url.openStream();
+        builder = new StAXOMBuilder(in);
+        
+        return builder;
+    }
+
+
+    /**
+     * todo add validation
+     * @param uri of the OMDocument
+     * @return an OMElement representing the document just read
+     * @throws IOException 
+     */
+    public static OMElement getElement(String uri) throws IOException, URISyntaxException, XMLStreamException {
+        StAXOMBuilder builder = OMUtils.getOMBuilder(uri);
+        return builder == null ? null : builder.getDocumentElement();
+    }
+
+    /**
+     * Returns the value of an attribute of an element. Returns null
+     * if the attribute is not found
+     * @param omElement Element whose attrib is looked for
+     * @param attrName  name of attribute to look for
+     * @return the attribute value
+     */
+    public static String getAttribute(OMElement omElement, String attrName) {
+        String val = null;
+        Iterator allAttr = omElement.getAllAttributes();
+        while(allAttr.hasNext()){
+            OMAttribute attr = (OMAttribute)allAttr.next();
+            if (attr.getLocalName().equals(attrName)){
+                val = attr.getAttributeValue();
+            }
+        }
+        return val;
+    }
+
+    /**
+     * @param element OMElement which would most probably contain <xs:schema>
+     * @return a SAX inputsource from the OMElement
+     */
+    public static InputSource getInputSource(OMElement element){
+
+        String elementString;
+        byte[] bytes = new byte[0];
+
+        //Obtain the String value of the OMElement after building the OM tree
+        try {
+            elementString = element.toStringWithConsume();
+            bytes= elementString.getBytes();
+        } catch (XMLStreamException e) {
+            e.printStackTrace();
+        }
+
+        //Deserialize from a byte array
+        InputStream inputStream = new ByteArrayInputStream(bytes);
+
+        return new InputSource(inputStream);
+    }
+    
+}
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/xpointer/OMXMLElementEvaluator.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/xpointer/OMXMLElementEvaluator.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/xpointer/OMXMLElementEvaluator.java (added)
+++ webservices/woden/trunk/java/woden-om/src/main/java/org/apache/woden/internal/xpointer/OMXMLElementEvaluator.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,83 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden.internal.xpointer;
+
+//Java
+import javax.xml.namespace.QName;
+
+//Woden
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.OMXMLElement;
+import org.apache.woden.ErrorReporter;
+
+//XPointer
+import org.apache.woden.xpointer.XPointer;
+
+//OM
+import org.apache.axiom.om.OMElement;
+
+/**
+ * This class extends XMLElementEvaluator to support the OM implementation in XMLElement
+ * 
+ * @author Dan Harvey <da...@gmail.com>
+ *
+ */
+public class OMXMLElementEvaluator extends XMLElementEvaluator {
+
+    /**
+     * Constructs a new OMXMLElementEvaluator to evaluate a XPointer on a OM Element.
+     * 
+     * @param xpointer an XPointer to evaluate.
+     * @param element an OMElement to be evaluated. 
+     * @param errorReporter the Woden Error Reporter context object.
+     */
+    public OMXMLElementEvaluator(XPointer xpointer, OMElement element, ErrorReporter errorReporter) {
+        super(xpointer, createXMLElement(element, errorReporter));
+    }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.woden.internal.xpointer.XMLElementEvaluator#testElementShorthand(org.apache.woden.XMLElement, java.lang.String)
+     */
+    public boolean testElementShorthand(XMLElement element, String shorthand) {
+        // Simple http://www.w3.org/TR/xml-id/ support for now until we support full scheme based ID's.
+        OMElement omElement = (OMElement)element.getSource();
+        String attr = omElement.getAttributeValue(new QName("http://www.w3.org/XML/1998/namespace", "id"));
+        return attr != null && attr.equals(shorthand);
+    }
+
+    /**
+     * Evaluates the XPointer on the root Element and returns the resulting
+     * Element or null.
+     * 
+     * @return an Element from the resultant evaluation of the root Element or
+     *         null if evaluation fails.
+     */
+    public OMElement evaluateElement() {
+        XMLElement element = evaluate();
+        if (element != null) return (OMElement) element.getSource();
+        return null;
+    }
+
+    // Private methods
+    private static XMLElement createXMLElement(Object elem, ErrorReporter errorReporter) {
+        OMXMLElement omXMLElement = new OMXMLElement(errorReporter);
+        omXMLElement.setSource(elem);
+        return omXMLElement;
+
+    }
+}

Added: webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java (added)
+++ webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Description;
+
+public class OMWSDLReaderTest extends TestCase{
+
+    private WSDLFactory omWSDLFactory = null;
+    private WSDLReader omWSDLReader = null;
+
+    public static Test suite(){
+	    return new TestSuite(OMWSDLReaderTest.class);
+    }
+
+    protected void setUp() throws Exception{
+        //Create wsdl20 factory and reader.
+	    try{
+            omWSDLFactory = WSDLFactory.newInstance("org.apache.woden.internal.OMWSDLFactory");
+            omWSDLReader = omWSDLFactory.newWSDLReader();
+        }
+	    catch (Exception e){
+            e.printStackTrace();
+        }
+	    //Set errorHandler
+	    omWSDLReader.getErrorReporter().setErrorHandler(new TestErrorHandler());
+    }
+
+    public void testReadValidWSDL20FromOM(){
+        Description desc = null;
+        try{
+          URL wsdlURL = getClass().getClassLoader().getResource("org/apache/woden/primer-hotelReservationService.wsdl");
+          desc = omWSDLReader.readWSDL(wsdlURL.toString());
+        }
+        catch(WSDLException e){
+            fail("Unexpected exception: " + e.getMessage());
+        }
+        assertNotNull("The description returned is null.", desc);
+    }
+
+    public void testReadInvalidWSDL20FromOM(){
+        try{
+            URL wsdlURL = getClass().getClassLoader().getResource("org/apache/woden/badDescriptionTags.wsdl");
+            omWSDLReader.readWSDL(wsdlURL.toString());
+            fail("Expected a WSDLException because the \"description\" tag was deliberately misspelt.");
+        }
+        catch(WSDLException e){
+            assertTrue("Expected a WSDLException with message containing \"WSDL501\", but got: " + e.getMessage() ,
+            e.getMessage().indexOf("WSDL501") > -1);
+        }
+    }
+    
+    public void testReadEmbeddedWSDLSourceFromOM() {
+        Description desc = null;
+        //Load in a WSDL 2.0 file
+        URL wsdlURL = getClass().getClassLoader().getResource("org/apache/woden/embeded.xml");
+
+        //Good Tests.
+        String[] goodFragids = new String[]{
+                //Shorthand
+                "#wsdlRoot", 
+                //element() scheme.
+                "#element(wsdlRoot)", "#element(first/1/2)", "#element(/1/1/2)", "#element(second/2)"
+                };
+
+        //Test fragids
+        for (int i=0; i< goodFragids.length; i++) {
+            try {
+               desc = omWSDLReader.readWSDL(wsdlURL.toString() + goodFragids[i]); 
+            } catch(WSDLException e) {
+               fail("Failed with unexpected exception: " + e);
+            }
+            assertNotNull("Failed to load the embedded wsdl20 description with fragid: " + goodFragids[i], desc);
+        }
+        
+        //Bad Tests - Invalid XPointer. (Can't programmatically see between bad syntax and not pointing unless we modify WSDLException)
+        String[] badFragids = new String[]{
+                //Shorthand - bad syntax.
+                "#wsdl#Root", "#wsd(Root",
+                //Shorthand - don't point.
+                "#wsdlRootElement", "#nonexistentFragment", 
+                //element() scheme. - bad syntax.
+                "#element(wsdlRoot//)", "#element(/wsdlRoot)", "#element(wsdlRoot/)", "#element(wsdl,Root/1/1/2)", "#element(second/a)", 
+                //element() scheme - don't point.
+                "#element(wsdlRoot/20)", "#element(/4/1/2)", "#element(second/3)"
+                };
+
+        //Test fragids
+        for (int i=0; i< badFragids.length; i++) {
+            try {
+               desc = omWSDLReader.readWSDL(wsdlURL.toString() + badFragids[i]); 
+            } catch(WSDLException e) {
+                assertEquals("Expected exception WSDL531 for invalid XPoitner: " + badFragids[i] + ", but got the exception: " + e, "PARSER_ERROR", e.getFaultCode());
+                continue;
+            }
+            fail("XPointer parse didn't not throw exception for invalid fragid: " + badFragids[i]);
+        }
+    }
+}
\ No newline at end of file

Added: webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMXMLElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMXMLElementTest.java?rev=809837&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMXMLElementTest.java (added)
+++ webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMXMLElementTest.java Tue Sep  1 05:56:01 2009
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.woden;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.internal.OMXMLElement;
+import org.apache.woden.internal.ErrorReporterImpl;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.internal.util.om.OMQNameUtils;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+
+public class OMXMLElementTest extends TestCase {
+
+    private URL wsdlURL = getClass().getClassLoader().getResource("org/apache/woden/primer-hotelReservationService.wsdl");
+    private ErrorReporter errorReporter;
+    private OMElement elem = null;
+
+  public static Test suite(){
+    return new TestSuite(OMXMLElementTest.class);
+  }
+
+  protected void setUp() throws Exception{
+      InputStream in = wsdlURL.openStream();
+      StAXOMBuilder builder = new StAXOMBuilder(in);
+      elem = builder.getDocumentElement();
+
+      errorReporter = new ErrorReporterImpl();
+
+  }
+
+  protected void tearDown() throws Exception{
+  }
+
+  public void testGetFirstChildElement() throws WSDLException {
+      OMXMLElement omXMLElement = new OMXMLElement(errorReporter);
+      omXMLElement.setSource(elem);
+      assertNotNull(omXMLElement.getFirstChildElement());
+  }
+
+  /* TODO implement this method only if getAttributes() is added to XMLElement.
+   * 
+    public void testGetAttributes() throws WSDLException {
+
+        //The <binding> element in the hotelReservation WSDL has many attributes
+        //So, let's test with that element
+        OMXMLElement omXMLElement = new OMXMLElement(errorReporter);
+        omXMLElement.setSource(elem);
+        Object obj;
+        OMElement tempEl;
+        if ((obj = omXMLElement.getSource()) instanceof OMElement){
+            tempEl = (OMElement)obj;
+            Iterator childEls = tempEl.getChildElements();
+            while (childEls.hasNext()){
+                OMElement childEl = (OMElement) childEls.next();
+                 if (OMQNameUtils.matches(Constants.Q_ELEM_BINDING, childEl)){
+                    omXMLElement.setSource(childEl);
+                    assertNotNull(omXMLElement.getAttributes());
+                }
+            }
+        }
+    }
+    */
+
+    public void testGetAttributeValue() throws WSDLException {
+        OMXMLElement omXMLElement = new OMXMLElement(errorReporter);
+        omXMLElement.setSource(elem);
+        Object obj;
+        OMElement tempEl;
+        if ((obj = omXMLElement.getSource()) instanceof OMElement){
+            tempEl = (OMElement)obj;
+            Iterator childEls = tempEl.getChildElements();
+            while (childEls.hasNext()){
+                OMElement childEl = (OMElement) childEls.next();
+                 if (OMQNameUtils.matches(Constants.Q_ELEM_BINDING, childEl)){
+                    omXMLElement.setSource(childEl);
+                    assertNotNull(omXMLElement.getAttributeValue("name"));
+                     break;
+                }
+
+            }
+
+        }
+    }
+
+    public void testGetQName() throws WSDLException {
+        OMXMLElement omXMLElement = new OMXMLElement(errorReporter);
+        omXMLElement.setSource(elem);
+        Object obj;
+        OMElement tempEl;
+        if ((obj = omXMLElement.getSource()) instanceof OMElement){
+            tempEl = (OMElement)obj;
+            Iterator childEls = tempEl.getChildElements();
+            while (childEls.hasNext()){
+                OMElement childEl = (OMElement) childEls.next();
+                 if (OMQNameUtils.matches(Constants.Q_ELEM_BINDING, childEl)){
+                    omXMLElement.setSource(childEl);
+                    assertNotNull(omXMLElement.getQName("wsoap:protocol"));
+                }
+            }
+        }
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org