ws-woden-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkapu...@apache.org
Subject svn commit: r327196 - /incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
Date Fri, 21 Oct 2005 14:16:29 GMT
Author: jkaputin
Date: Fri Oct 21 07:16:22 2005
New Revision: 327196

URL: http://svn.apache.org/viewcvs?rev=327196&view=rev
Log:
Tidying up of code and comments and added some error
reporting per woden-dev posting 12 Oct 05 titled
"Plan to handle parsing errors and validation."

Modified:
    incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.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=327196&r1=327195&r2=327196&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Fri Oct 21 07:16:22
2005
@@ -124,6 +124,15 @@
         }
     }
     
+    /* Parse the attributes and child elements of the <description> element.
+     * As per the WSDL 2.0 spec, the child elements must be in the 
+     * following order if present:
+     * <documentation>
+     * <import> <include> or WSDL extension elements in any order
+     * <types>
+     * <interface> <binding> <service> or WSDL extension elements in any
order.
+     * TODO validate that the elements are in correct order
+     */ 
     private DescriptionElement parseDescription(String documentBaseURI, 
                                                 Element descEl, 
                                                 Map importedDescs) 
@@ -138,8 +147,7 @@
 
         //TODO set extension registry here or let factory set it in newDescription?
         
-        //parse target namespace attribute
-        
+        //target namespace is of type xs:AnyURI, so store the string
         String targetNamespace = 
             DOMUtils.getAttribute(descEl, Constants.ATTR_TARGET_NAMESPACE);
         
@@ -151,21 +159,16 @@
         {
             //The targetNamespace attribute is REQUIRED on wsdl:description.
             //(WSDL 2.0 W3C spec, Part 2: 2.1.2)
-            
             getErrorReporter().reportError(
                 "WSDL009", 
                 new Object[] {documentBaseURI}, 
                 ErrorReporter.SEVERITY_FATAL_ERROR);
-            
-            //Won't be able to create qnames for other elements during the
-            //rest of the parse so don't continue.
-            return desc;
-        }
+
+            //TODO terminate if validation=false and continue-on-error=false.
+       }
         
         //parse the namespace declarations
-        
         NamedNodeMap attrs = descEl.getAttributes();
-
         int size = attrs.getLength();
 
         for (int i = 0; i < size; i++)
@@ -175,9 +178,9 @@
           String localPart = attr.getLocalName();
           String value = attr.getValue();
 
-          if (namespaceURI != null && namespaceURI.equals(Constants.NS_URI_XMLNS))
+          if ((Constants.NS_URI_XMLNS).equals(namespaceURI))
           {
-            if (localPart != null && !localPart.equals(Constants.ATTR_XMLNS))
+            if (!(Constants.ATTR_XMLNS).equals(localPart))
             {
               desc.addNamespace(localPart, value);  //a prefixed namespace
             }
@@ -188,15 +191,9 @@
           }
         }
         
-        /* Parse the child elements. As per the WSDL 2.0 spec, 
-         * they must be in the following order if present:
-         * <documentation>
-         * <import> <include> or WSDL extension elements in any order
-         * <types>
-         * <interface> <binding> <service> or WSDL extension elements in
any order.
-         * TODO validate that the elements are in correct order
-         */ 
-
+        //TODO extension attributes
+        
+        //parse the child elements
         Element tempEl = DOMUtils.getFirstChildElement(descEl);
 
         while (tempEl != null)
@@ -215,7 +212,7 @@
             }
             else
             {
-                //TODO document, import, include, binding, service, extensions
+                //TODO import, include, binding, service, extension elements
             }
             
             tempEl = DOMUtils.getNextSiblingElement(tempEl);
@@ -237,17 +234,16 @@
     {
         FeatureElement feature = desc.createFeatureElement();
 
-        String ref = 
-            DOMUtils.getAttribute(featEl, Constants.ATTR_REF);
-        
-        feature.setRef(ref);
+        //ref is of type xs:AnyURI, so store as a String
+        feature.setRef(DOMUtils.getAttribute(featEl, Constants.ATTR_REF));
+        //TODO ref is required, so terminate if validation=false and continue-on-error=false.
         
         String req = 
             DOMUtils.getAttribute(featEl, Constants.ATTR_REQUIRED);
         
         feature.setRequired("true".equals(req) ? true : false);
         
-        //TODO t.b.c. what if attr value is not 'true' or 'false'? (eg, missing, mispelt
or case change)
+        //TODO t.b.c. what if attr value is not 'true' or 'false'? (eg, missing, mispelt
or not lower case.
         
         //TODO extension attributes
         
@@ -269,7 +265,7 @@
             }
             else
             {
-                //TODO extensions
+                //TODO extension elements
             }
             
             tempEl = DOMUtils.getNextSiblingElement(tempEl);
@@ -293,18 +289,25 @@
     {
         InterfaceElement intface = desc.createInterfaceElement();
 
-        String localName = 
+        String name = 
             DOMUtils.getAttribute(interfaceEl, Constants.ATTR_NAME);
         
-        if(localName != null)
+        if(name != null)
         {
-            QName qname = new QName(desc.getTargetNamespace(), localName);
+            QName qname = QNameUtils.newQName(desc.getTargetNamespace(), 
+                                              name);
             intface.setName(qname);
         }
-        //TODO what if name null? Handle here or leave to validator?
+        else
+        {
+            //If validation is on, let the validator handle this.
+            //TODO terminate if validation=false and continue-on-error=false.
+        }
+        
         
         //TODO extends attribute
         //TODO styleDefault attribute
+        //TODO extension attributes
         
         /* Parse the child elements of <interface>. 
          * As per WSDL 2.0 spec, they must be in the following order if present:
@@ -339,7 +342,7 @@
             }
             else
             {
-                //TODO extensions
+                //TODO extension elements
             }
             
             tempEl = DOMUtils.getNextSiblingElement(tempEl);
@@ -348,6 +351,13 @@
         return intface;
     }
 
+    /* Parse the attributes and child elements of interface <fault>. 
+     * As per WSDL 2.0 spec, the child elements must be in the following order if present:
+     * <documentation>
+     * <feature> <property> or extension elements in any order
+     * 
+     * TODO validate that the elements are in correct order
+     */ 
     private InterfaceFaultElement parseInterfaceFault(
                                              Element faultEl,
                                              DescriptionElement desc) 
@@ -355,15 +365,19 @@
     {
         InterfaceFaultElement fault = desc.createInterfaceFaultElement();
         
-        String localName = 
+        String name = 
             DOMUtils.getAttribute(faultEl, Constants.ATTR_NAME);
         
-        if(localName != null)
+        if(name != null)
         {
-            QName qname = new QName(desc.getTargetNamespace(), localName);
+            QName qname = QNameUtils.newQName(desc.getTargetNamespace(), name);
             fault.setName(qname);
         }
-        //TODO what if name null? Handle here or leave to validator?
+        else
+        {
+            //If validation is on, let the validator handle this.
+            //TODO terminate if validation=false and continue-on-error=false.
+        }
         
         String element = 
             DOMUtils.getAttribute(faultEl, Constants.ATTR_ELEMENT);
@@ -373,22 +387,14 @@
             QName qname = DOMUtils.getQName(element, faultEl, desc);
             fault.setElement(qname);
         } catch (WSDLException e) {
-            //Bad qname, so ignore element attribute and let validator handle it later.
-            
-            //TODO Confirm that validator can handle this later. One problem might be
-            //that the context is gone, so the validator cannot tell if the element attr
-            //was missing or if the qname string had an unbound prefix.
+            //report the parse-time error and let the validator handle it.
+            getErrorReporter().reportError("WSDL504",
+                                            new Object[] {"element", "fault"}, 
+                                            ErrorReporter.SEVERITY_ERROR);
+            //TODO if validation is off and continue-on-error is off, terminate here
         }
         
         //TODO extension attributes
-        
-        /* Parse the child elements of interface <fault>. 
-         * As per WSDL 2.0 spec, they must be in the following order if present:
-         * <documentation>
-         * <fault> <operation> <feature> <property> or extension
elements in any order
-         * 
-         * TODO validate that the elements are in correct order
-         */ 
 
         Element tempEl = DOMUtils.getFirstChildElement(faultEl);
 
@@ -408,7 +414,7 @@
             }
             else
             {
-                //TODO extensions
+                //TODO extension elements
             }
             
             tempEl = DOMUtils.getNextSiblingElement(tempEl);
@@ -460,10 +466,9 @@
     {
         PropertyElement property = desc.createPropertyElement();
         
-        String ref = 
-            DOMUtils.getAttribute(propEl, Constants.ATTR_REF);
-        
-        property.setRef(ref);
+        //ref is of type xs:AnyURI, so store as a String
+        property.setRef(DOMUtils.getAttribute(propEl, Constants.ATTR_REF));
+        //TODO ref is required, so terminate if validation=false and continue-on-error=false.
         
         //TODO extension attributes
         
@@ -480,7 +485,7 @@
                 //the property value consists of the child info items of <value>
                 NodeList nodeList = tempEl.getChildNodes();
                 property.setValue(nodeList);
-           }
+            }
             else if(QNameUtils.matches(Constants.Q_ELEM_CONSTRAINT, tempEl))
             {
                 //TODO t.b.c. assume <constraint> has just '#value' or a qname 
@@ -510,6 +515,7 @@
                                         new Object[] {textValue, tempEl.getLocalName()},
                                         ErrorReporter.SEVERITY_ERROR,
                                         e);
+                                //TODO terminate if validation is off and continue-on-error
is off
                             }
                         }
                     }
@@ -517,7 +523,7 @@
             }
             else
             {
-                //TODO extensions
+                //TODO extension elements
             }
             
             tempEl = DOMUtils.getNextSiblingElement(tempEl);
@@ -827,6 +833,8 @@
         //TODO for now set to W3 XML Schema. Later,
         //add support for non-XML Schema type systems
         types.setTypeSystem(Constants.TYPE_XSD_2001);
+        
+        //TODO extension attributes
 
         Element tempEl = DOMUtils.getFirstChildElement(typesEl);
 
@@ -850,7 +858,7 @@
             }
             else
             {
-                //TODO extensions for non-XML and non-XMLSchema type systems
+                //TODO extensions element (e.g. for xml type systems that are not W3C XML
Schema)
             }
             
             tempEl = DOMUtils.getNextSiblingElement(tempEl);



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


Mime
View raw message