axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/test/clash AirportWeather.xml
Date Wed, 05 Dec 2001 18:52:26 GMT
butek       01/12/05 10:52:26

  Modified:    java/src/org/apache/axis/utils resources.properties
               java/src/org/apache/axis/wsdl JavaWriterFactory.java
                        SymbolTable.java
               java/test/clash AirportWeather.xml
  Log:
  I wanted to make duplicate types illegal, but it turned out to require lots of other
  changes:
  - the following is legal WSDL:
  <complexType name="X".../>
  <element name="X" ref="X"/>
  I had to accept this while not accepting:
  <complexType name="X".../>
  <complexType name="X".../>
  - only parse imported files once, otherwise types in that file were treated as illegal
  duplicates (ie., if W import X and Y and both of those imported Z, we used to parse Z
  twice).
  - expanded the name clash algorithm (and the test).
  - removed complexType elements from the symbol table (otherwise they could
  clash with type names).
  
  Revision  Changes    Path
  1.22      +5 -0      xml-axis/java/src/org/apache/axis/utils/resources.properties
  
  Index: resources.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- resources.properties	2001/12/05 18:34:14	1.21
  +++ resources.properties	2001/12/05 18:52:26	1.22
  @@ -568,3 +568,8 @@
   deploy07=<!--   java org.apache.axis.client.AdminClient deploy.wsdd       -->
   deploy08=<!--   java org.apache.axis.client.AdminClient undeploy.wsdd     -->
   deploy09=<!--      after the axis server is running                       -->
  +
  +# NOTE to developers!  All messages above this line are alpha3 messages.  Do
  +# not change or add any new messages above this line!
  +
  +alreadyExists00={0} already exists
  
  
  
  1.12      +4 -1      xml-axis/java/src/org/apache/axis/wsdl/JavaWriterFactory.java
  
  Index: JavaWriterFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/JavaWriterFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JavaWriterFactory.java	2001/12/04 19:34:56	1.11
  +++ JavaWriterFactory.java	2001/12/05 18:52:26	1.12
  @@ -175,7 +175,10 @@
               if (v.size() > 1) {
                   for (int i = 0; i < v.size(); ++i) {
                       SymTabEntry entry = (SymTabEntry) v.elementAt(i);
  -                    if (entry instanceof Type) {
  +                    if (entry instanceof ElementType) {
  +                        entry.setName(entry.getName() + "_ElemType");
  +                    }
  +                    else if (entry instanceof Type) {
                           entry.setName(entry.getName() + "_Type");
                       }
                       else if (entry instanceof PortTypeEntry) {
  
  
  
  1.16      +47 -17    xml-axis/java/src/org/apache/axis/wsdl/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/SymbolTable.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SymbolTable.java	2001/12/04 19:43:29	1.15
  +++ SymbolTable.java	2001/12/05 18:52:26	1.16
  @@ -189,6 +189,7 @@
        * Add the given Definition and Document information to the symbol table (including
imported
        * symbols), populating it with SymTabEntries for each of the top-level symbols.
        */
  +    private HashSet importedFiles = new HashSet();
       private void populate(Definition def, Document doc) throws IOException {
           if (doc != null) {
               populateTypes(doc);
  @@ -202,8 +203,11 @@
                       Vector v = (Vector) imports.get(importKeys[i]);
                       for (int j = 0; j < v.size(); ++j) {
                           Import imp = (Import) v.get(j);
  -                        populate(imp.getDefinition(),
  -                            XMLUtils.newDocument(imp.getLocationURI()));
  +                        if (!importedFiles.contains(imp.getLocationURI())) {
  +                            importedFiles.add(imp.getLocationURI());
  +                            populate(imp.getDefinition(),
  +                                    XMLUtils.newDocument(imp.getLocationURI()));
  +                        }
                       }
                   }
               }
  @@ -217,15 +221,22 @@
       /**
        * Populate the symbol table with all of the Types from the Document.
        */
  -    private void populateTypes(Document doc) {
  -        addTypes(doc);
  +    private void populateTypes(Document doc) throws IOException {
  +        addTypes(doc, ABOVE_SCHEMA_LEVEL);
       } // populateTypes
   
       /**
        * Utility method which walks the Document and creates Type objects for
        * each complexType, simpleType, or element referenced or defined.
  -     */
  -    private void addTypes(Node node) {
  +     *
  +     * What goes into the symbol table?  In general, only the top-level types (ie., those
just below
  +     * the schema tag).  But base types and references can appear below the top level.
 So anything
  +     * at the top level is added to the symbol table, plus non-Element types (ie, base
and refd)
  +     * that appear deep within other types.
  +     */
  +    private static final int ABOVE_SCHEMA_LEVEL = -1;
  +    private static final int SCHEMA_LEVEL = 0;
  +    private void addTypes(Node node, int level) throws IOException {
           if (node == null) {
               return;
           }
  @@ -238,14 +249,14 @@
   
                   // This is a definition of a complex type.
                   // Create a Type.
  -                createTypeFromDef(node, false);
  +                createTypeFromDef(node, false, false);
               }
               if (nodeKind.getLocalPart().equals("simpleType") &&
                   Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
   
                   // This is a definition of a simple type, which could be an enum
                   // Create a Type.
  -                createTypeFromDef(node, false);
  +                createTypeFromDef(node, false, false);
               }
               else if (nodeKind.getLocalPart().equals("element") &&
                      Utils.isSchemaNS(nodeKind.getNamespaceURI())) {
  @@ -259,7 +270,7 @@
                   // Create a type representing an element.  (This may
                   // seem like overkill, but is necessary to support ref=
                   // and element=.
  -                createTypeFromDef(node, true);
  +                createTypeFromDef(node, true, level > SCHEMA_LEVEL);
               }
               else if (nodeKind.getLocalPart().equals("part") &&
                        Utils.isWsdlNS(nodeKind.getNamespaceURI())) {
  @@ -268,10 +279,20 @@
                   createTypeFromRef(node);
               }
           }
  +
  +        if (level == ABOVE_SCHEMA_LEVEL) {
  +            if (nodeKind != null && nodeKind.getLocalPart().equals("schema")) {
  +                level = SCHEMA_LEVEL;
  +            }
  +        }
  +        else {
  +            ++level;
  +        }
  +
           // Recurse through children nodes
           NodeList children = node.getChildNodes();
           for (int i = 0; i < children.getLength(); i++) {
  -            addTypes(children.item(i));
  +            addTypes(children.item(i), level);
           }
       } // addTypes
   
  @@ -279,7 +300,8 @@
        * Create a Type from the indicated node, which defines a type
        * that represents a complexType, simpleType or element (for ref=).
        */
  -    private void createTypeFromDef(Node node, boolean isElement) {
  +    private void createTypeFromDef(Node node, boolean isElement,
  +            boolean belowSchemaLevel) throws IOException {
           // If this is not an element, make sure it is not an anonymous type.
           // If it is, the the existing ElementType will be used.  If
           // not, create a new type.
  @@ -307,7 +329,9 @@
                       }                         
                   }
                   // Create a type from the referenced type
  -                symbolTablePut(new ElementType(qName, refType, node));
  +                if (!belowSchemaLevel) {
  +                    symbolTablePut(new ElementType(qName, refType, node));
  +                }
   
               }   
               else {
  @@ -346,7 +370,7 @@
        * Node may contain a reference (via type=, ref=, or element= attributes) to 
        * another type.  Create a Type object representing this referenced type.
        */
  -    private void createTypeFromRef(Node node) {
  +    private void createTypeFromRef(Node node) throws IOException {
           // Get the QName of the node's type attribute value
           QName qName = Utils.getNodeTypeRefQName(node);
           if (qName != null) {
  @@ -401,7 +425,7 @@
       /**
        * Populate the symbol table with all of the MessageEntry's from the Definition.
        */
  -    private void populateMessages(Definition def) {
  +    private void populateMessages(Definition def) throws IOException {
           Iterator i = def.getMessages().values().iterator();
           while (i.hasNext()) {
               Message message = (Message) i.next();
  @@ -629,7 +653,7 @@
       /**
        * Populate the symbol table with all of the BindingEntry's from the Definition.
        */
  -    private void populateBindings(Definition def) {
  +    private void populateBindings(Definition def) throws IOException {
           Iterator i = def.getBindings().values().iterator();
           while (i.hasNext()) {
               int bindingStyle = BindingEntry.STYLE_RPC;
  @@ -739,7 +763,7 @@
       /**
        * Populate the symbol table with all of the ServiceEntry's from the Definition.
        */
  -    private void populateServices(Definition def) {
  +    private void populateServices(Definition def) throws IOException {
           Iterator i = def.getServices().values().iterator();
           while (i.hasNext()) {
               Service service = (Service) i.next();
  @@ -1000,7 +1024,7 @@
       /**
        * Put the given SymTabEntry into the symbol table, if appropriate.  If 
        */
  -    private void symbolTablePut(SymTabEntry entry) {
  +    private void symbolTablePut(SymTabEntry entry) throws IOException {
           QName name = entry.getQName();
           if (get(name, entry.getClass()) == null) {
               // An entry of the given qname of the given type doesn't exist yet.
  @@ -1040,6 +1064,10 @@
                   }
               }
           }
  +        else {
  +            throw new IOException(
  +                    JavaUtils.getMessage("alreadyExists00", "" + name));
  +        }
       } // symbolTablePut
   
       /**
  @@ -1183,6 +1211,8 @@
           while (it.hasNext()) {
               Vector v = (Vector) it.next();
               for (int i = 0; i < v.size(); ++i) {
  +                out.println(
  +                        v.elementAt(i).getClass().getName());
                   out.println(v.elementAt(i));
               }
           }
  
  
  
  1.3       +35 -16    xml-axis/java/test/clash/AirportWeather.xml
  
  Index: AirportWeather.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/clash/AirportWeather.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AirportWeather.xml	2001/11/26 16:58:38	1.2
  +++ AirportWeather.xml	2001/12/05 18:52:26	1.3
  @@ -1,22 +1,41 @@
   <?xml version="1.0" encoding="UTF-8"?>
  -<definitions name="AirportWeather" targetNamespace="http://www.capeclear.com/AirportWeather.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.capeclear.com/AirportWeather.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1="http://www.capeclear.com/AirportWeather.wsdl">
  -<types>
  -<xsd:schema targetNamespace="http://www.capeclear.com/AirportWeather.wsdl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  -<xsd:complexType name="AirportWeather">
  -<xsd:sequence>
  -<xsd:element maxOccurs="1" minOccurs="1" name="location" type="xsd:string"/>
  -<xsd:element maxOccurs="1" minOccurs="1" name="wind" type="xsd:string"/>
  -<xsd:element maxOccurs="1" minOccurs="1" name="sky" type="xsd:string"/>
  -<xsd:element maxOccurs="1" minOccurs="1" name="temp" type="xsd:string"/>
  -<xsd:element maxOccurs="1" minOccurs="1" name="humidity" type="xsd:string"/>
  -<xsd:element maxOccurs="1" minOccurs="1" name="pressure" type="xsd:string"/>
  -<xsd:element maxOccurs="1" minOccurs="1" name="visibility" type="xsd:string"/>
  -</xsd:sequence>
  -</xsd:complexType>
  -</xsd:schema>
  +<definitions name="AirportWeather"
  +    targetNamespace="http://www.capeclear.com/AirportWeather.wsdl"
  +    xmlns="http://schemas.xmlsoap.org/wsdl/"
  +    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  +    xmlns:tns="http://www.capeclear.com/AirportWeather.wsdl"
  +    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  +    xmlns:xsd1="http://www.capeclear.com/AirportWeather.wsdl">
  +  <types>
  +    <xsd:schema
  +        targetNamespace="http://www.capeclear.com/AirportWeather.wsdl"
  +        xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  +        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  +        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  +      <xsd:complexType name="AirportWeather">
  +        <xsd:sequence>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="location" type="xsd:string"/>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="wind" type="xsd:string"/>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="sky" type="xsd:string"/>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="temp" type="xsd:string"/>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="humidity" type="xsd:string"/>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="pressure" type="xsd:string"/>
  +        <xsd:element maxOccurs="1" minOccurs="1" name="visibility" type="xsd:string"/>
  +      </xsd:sequence>
  +    </xsd:complexType>
  +
  +    <xsd:complexType name="SameForTypeAndElement">
  +      <xsd:all>
  +        <xsd:element name="str" type="xsd:string"/>
  +      </xsd:all>
  +    </xsd:complexType>
  +
  +    <xsd:element name="SameForTypeAndElement" ref="SameForTypeAndElement"/>
  +
  +  </xsd:schema>
   </types>
   <message name="getLocation">
  -<part name="arg0" type="xsd:string"/>
  +<part name="arg0" type="xsd1:SameForTypeAndElement"/>
   </message>
   <message name="getLocationResponse">
   <part name="return" type="xsd:string"/>
  
  
  

Mime
View raw message