axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/types ComprehensiveTypes.wsdl
Date Wed, 28 Aug 2002 22:53:18 GMT
scheu       2002/08/28 15:53:18

  Modified:    java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java
                        SymbolTable.java Utils.java
               java/src/org/apache/axis/wsdl/toJava
                        JavaGeneratorFactory.java JavaStubWriter.java
                        Utils.java
               java/test/wsdl/types ComprehensiveTypes.wsdl
  Log:
  Changes are made to cleanup symbolTable.Utils.getNodeTypeRefQName methods.
  These changes were necessary to fix bug(s) submitted to me by Damian Hagge
  involving maxOccurs on an element that has an anonymous type.
  
  Discussion of changes:
  
  org.apache.axis.wsdl.symbolTable.Utils has two methods named getNodeTypeRefQName.
  The shared names plus convoluted logic has made it difficult to understand
  the operation of these methods.
  
  ---------------------------------------------------------------------------
  The first getNodeTypeRefQName method is changed to
   public static QName getTypeQName(Node node,
                                    BooleanHolder forElement,
                                    boolean ignoreMaxOccurs)
  The purpose of the method is to get the <i>type</i> QName of the specified node.
  So if the node is:
     <element name="foo" type="bar" />
  the QName representing "bar" is returned.
  
  Likewise it the node is:
     <element ref="bar" />
  the QName representing "bar" is returned (and the forElement flag is turned
  on to indicate that the QName is an element not a type).
  
  And if the node is
     <element name="bar">
        <complexType>
           ...
        </complexType>
  then the QName representing the anonymous type is returned.
  
  And if the node is
     <element name="foo" type="bar" maxOccurs="unbounded" />
  then the QName representing the collection of bar types is returned.
  (Or you can set ignoreMaxOccurs to get just the component "bar" QName.)
  
  ...The point is...getTypeQName is now a fully functioning routine
  that returns the QName representing the type of the indicated node.
  
  ---------------------------------------------------------------
  The second getNodeTypeRefQName method is changed to:
  
  private static QName getTypeQNameFromAttr(Node node,
          String typeAttrName);
  
  NOTE THAT THIS IS NOW PRIVATE!  The getTypeQName() method
  should always be used.
  
  The purpose of this method is simply to get the
  type QName of the node via the indicated attribute name.
  
  So getTypeQNameFromAttr(node, "ref") tries to get a type
  QName by examining the "ref" attribute.
  
  An invocation of getTypeQNameFromAttr(node, "type")
  tries to get a type QName by examinging the "type" attribute.
  If not successful, the code automatically looks for an
  anonymous type.
  
  ----------------------------------------------------------------
  
  I then changed all references to get NodeTypeRefQName to use
  one of the two new methods.  This cleaned up some code.
  
  I also needed to clean up the JavaGeneratorFactory.javifyNames
  code to handle Damian's case.
  
  And I cleaned up some code in Utils.getNestedTypes
  
  These changes are not as scary as the diff makes them appear :-)
  
  Revision  Changes    Path
  1.15      +20 -31    xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java
  
  Index: SchemaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SchemaUtils.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SchemaUtils.java	28 Aug 2002 17:02:36 -0000	1.14
  +++ SchemaUtils.java	28 Aug 2002 22:53:17 -0000	1.15
  @@ -149,10 +149,9 @@
                           extensionKind.getLocalPart().equals("extension") &&
                           Constants.isSchemaXSD(extensionKind.getNamespaceURI())) {
                           
  -                        // get the type of the extension
  +                        // get the type of the extension from the "base" attribute
                           QName extendsType =
  -                                Utils.getNodeTypeRefQName(children.item(j), 
  -                                                          "base");
  +                            Utils.getTypeQName(children.item(j), new BooleanHolder(), false);
                           
                           // Return an element declaration with a fixed name
                           // ("value") and the correct type.                        
  @@ -342,12 +341,8 @@
   
           // The type qname is used to locate the TypeEntry, which is then
           // used to retrieve the proper java name of the type.
  -        QName nodeType = Utils.getNodeTypeRefQName(elementNode, forElement);
  +        QName nodeType = Utils.getTypeQName(elementNode, forElement, false);
   
  -        if (nodeType == null) {
  -            nodeType = getElementAnonQName(elementNode);            
  -            forElement.value = false;
  -        }        
           TypeEntry type = (TypeEntry)symbolTable.getTypeEntry(nodeType, 
                                                                forElement.value);
   
  @@ -564,7 +559,7 @@
               }
   
               // Get the QName of the extension base
  -            QName extendsType = Utils.getNodeTypeRefQName(extension, "base");
  +            QName extendsType = Utils.getTypeQName(extension, new BooleanHolder(), false);
               if (extendsType == null) {
                   return null; // No extension base
               }
  @@ -624,7 +619,7 @@
               // (the base attribute contains this type).
               
               if (restrictionNode != null) {
  -                baseQName = Utils.getNodeTypeRefQName(restrictionNode, "base");
  +                baseQName = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false);
               }
               
               // Look for enumeration elements underneath the restriction node
  @@ -751,19 +746,15 @@
               nodeKind.getLocalPart().equals("element") &&
               Constants.isSchemaXSD(nodeKind.getNamespaceURI())) {
   
  -            // Get the qName of just the type or just the ref
  -            // The compare it against the full type of the node, which
  -            // takes into account maxOccurs and could return a collection type.
  -            // If different, return just the type (which is the collection component).
  -            QName componentQName = Utils.getNodeTypeRefQName(node, "type");
  -            if (componentQName == null) {
  -                componentQName = Utils.getNodeTypeRefQName(node, "ref");
  -            }
  -
  +            // Compare the componentQName with the name of the
  +            // full name.  If different, return componentQName
  +            BooleanHolder forElement = new BooleanHolder();
  +            QName componentQName = Utils.getTypeQName(node, forElement, true);
               if (componentQName != null) {
  -                QName fullTypeQName = Utils.getNodeTypeRefQName(node, new BooleanHolder());
  -                if (componentQName != fullTypeQName)
  +                QName fullQName = Utils.getTypeQName(node, forElement, false);
  +                if (!componentQName.equals(fullQName)) {
                       return componentQName;
  +                }
               }
           }
           return null;
  @@ -854,10 +845,10 @@
                   }
               }
   
  -            // The restriction node must have a base of soapenc:Array.  
  +            // The restriction node must have a base of soapenc:Array.              
               QName baseType = null;
               if (restrictionNode != null) {
  -                baseType = Utils.getNodeTypeRefQName(restrictionNode, "base");
  +                baseType = Utils.getTypeQName(restrictionNode, new BooleanHolder(), false);
                   if (baseType != null &&
                       baseType.getLocalPart().equals("Array") &&
                       Constants.isSOAP_ENC(baseType.getNamespaceURI()))
  @@ -888,8 +879,10 @@
                           Constants.isSchemaXSD(kind.getNamespaceURI())) {
                           // If the attribute node does not have ref="soapenc:arrayType"
                           // then keep looking.
  -                        QName refQName = Utils.getNodeTypeRefQName(children.item(j), "ref");
  +                        BooleanHolder isRef = new BooleanHolder();
  +                        QName refQName = Utils.getTypeQName(children.item(j), isRef, false);
                           if (refQName != null &&
  +                            isRef.value &&
                               refQName.getLocalPart().equals("arrayType") &&
                               Constants.isSOAP_ENC(refQName.getNamespaceURI())) {
                               attributeNode = children.item(j);
  @@ -950,9 +943,9 @@
                       String maxOccursValue = Utils.getAttribute(elementNode, "maxOccurs");
                       if (maxOccursValue != null &&
                           maxOccursValue.equalsIgnoreCase("unbounded")) {
  -                        // Get the QName of just the type
  +                        // Get the QName of the type without considering maxOccurs
                           dims.value = 1;
  -                        return Utils.getNodeTypeRefQName(elementNode, "type");
  +                        return Utils.getTypeQName(elementNode, new BooleanHolder(), true);
                       }
                   }
               }
  @@ -1061,7 +1054,7 @@
                   // used to retrieve the proper java name of the type.
                   QName attributeName = Utils.getNodeNameQName(child);
                   BooleanHolder forElement = new BooleanHolder();
  -                QName attributeType = Utils.getNodeTypeRefQName(child, forElement);
  +                QName attributeType = Utils.getTypeQName(child, forElement, false);
   
                   // An attribute is either qualified or unqualified.
                   // If the ref= attribute is used, the name of the ref'd element is used
  @@ -1086,10 +1079,6 @@
                       }
                   } else {
                       attributeName = attributeType;
  -                }
  -                if (attributeType == null) {
  -                    attributeType = getAttributeAnonQName(child);            
  -                    forElement.value = false;
                   }
                   
                   // Get the corresponding TypeEntry from the symbol table
  
  
  
  1.28      +44 -51    xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/SymbolTable.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- SymbolTable.java	28 Aug 2002 17:02:36 -0000	1.27
  +++ SymbolTable.java	28 Aug 2002 22:53:17 -0000	1.28
  @@ -660,12 +660,8 @@
                   createTypeFromDef(node, false, false);
               }
               else if (isXSD && localPart.equals("element")) {
  -                // If the element has a type/ref attribute, create
  -                // a Type representing the referenced type.
  -                if (Utils.getNodeTypeRefQName(node, "type") != null ||
  -                    Utils.getNodeTypeRefQName(node, "ref") != null) {
  -                    createTypeFromRef(node);
  -                }
  +                // Create a type entry for the referenced type
  +                createTypeFromRef(node);
   
                   // If an extension or restriction is present,
                   // create a type for the reference
  @@ -681,29 +677,30 @@
                   createTypeFromDef(node, true, level > SCHEMA_LEVEL);
               }
               else if (isXSD && localPart.equals("attribute")) {
  -                // If the attribute has a type/ref attribute, create
  -                // a Type representing the referenced type.
  -                if (Utils.getNodeTypeRefQName(node, "type") != null) {
  +                // Create a type entry for the referenced type
  +                BooleanHolder forElement = new BooleanHolder();
  +                QName refQName = Utils.getTypeQName(node, forElement, false);
  +                
  +                if (refQName != null && !forElement.value) {
                       createTypeFromRef(node);
  -                }
  -
  -                // Get the symbol table entry and make sure it is a simple 
  -                // type
  -                QName refQName = Utils.getNodeTypeRefQName(node, "type");
  -                if (refQName != null) {
  -                    TypeEntry refType = getTypeEntry(refQName, false);
  -                    if (refType != null &&
  -                        refType instanceof Undefined) {
  -                        // Don't know what the type is.
  -                        // It better be simple so set it as simple
  -                        refType.setSimpleType(true);
  -                    } else if (refType == null ||
  -                               (!(refType instanceof BaseType) &&
  -                                !refType.isSimpleType())) {
  -                        // Problem if not simple
  -                        throw new IOException(
  -                                              JavaUtils.getMessage("AttrNotSimpleType01",
  -                                                                   refQName.toString()));
  +                    
  +                    // Get the symbol table entry and make sure it is a simple 
  +                    // type
  +                    if (refQName != null) {
  +                        TypeEntry refType = getTypeEntry(refQName, false);
  +                        if (refType != null &&
  +                            refType instanceof Undefined) {
  +                            // Don't know what the type is.
  +                            // It better be simple so set it as simple
  +                            refType.setSimpleType(true);
  +                        } else if (refType == null ||
  +                                   (!(refType instanceof BaseType) &&
  +                                    !refType.isSimpleType())) {
  +                            // Problem if not simple
  +                            throw new IOException(
  +                                                  JavaUtils.getMessage("AttrNotSimpleType01",
  +                                                                       refQName.toString()));
  +                        }
                       }
                   }
               }
  @@ -765,7 +762,7 @@
               // If the node has a type or ref attribute, get the 
               // qname representing the type
               BooleanHolder forElement = new BooleanHolder();
  -            QName refQName = Utils.getNodeTypeRefQName(node, forElement);
  +            QName refQName = Utils.getTypeQName(node, forElement, false);
   
               if (refQName != null) {
                   // Now get the TypeEntry
  @@ -868,7 +865,7 @@
       private void createTypeFromRef(Node node) throws IOException {
           // Get the QName of the node's type attribute value
           BooleanHolder forElement = new BooleanHolder();
  -        QName qName = Utils.getNodeTypeRefQName(node, forElement);
  +        QName qName = Utils.getTypeQName(node, forElement, false);
           if (qName != null) {
               
               // Get Type or Element depending on whether type attr was used.
  @@ -878,32 +875,28 @@
               if (type == null) {
                   // See if this is a special QName for collections
                   if (qName.getLocalPart().indexOf("[") > 0) {
  -                    QName typeAttr = Utils.getNodeTypeRefQName(node, "type");
  -                    if (typeAttr != null) {
  +                    QName containedQName = Utils.getTypeQName(node, forElement, true);
  +                    TypeEntry containedTE = getTypeEntry(containedQName, forElement.value);
  +                    if (!forElement.value) {
                           // Case of type and maxOccurs
  -                        TypeEntry collEl = getTypeEntry(typeAttr, false);
  -                        if (collEl == null) {
  +                        if (containedTE == null) {
                               // Collection Element Type not defined yet, add one.
  -                            String baseName = btm.getBaseName(typeAttr);
  +                            String baseName = btm.getBaseName(containedQName);
                               if (baseName != null) {
  -                                collEl = new BaseType(typeAttr);
  +                                containedTE = new BaseType(containedQName);
                               } else {
  -                                collEl = new UndefinedType(typeAttr);
  +                                containedTE = new UndefinedType(containedQName);
                               }
  -                            symbolTablePut(collEl);
  +                            symbolTablePut(containedTE);
                           }
  -                        symbolTablePut(new CollectionType(qName, collEl, node, "[]"));
  +                        symbolTablePut(new CollectionType(qName, containedTE, node, "[]"));
                       } else {
                           // Case of ref and maxOccurs
  -                        QName refAttr = Utils.getNodeTypeRefQName(node, "ref");
  -                        if (refAttr != null) {
  -                            TypeEntry collEl = getTypeEntry(refAttr, true);
  -                            if (collEl == null) {
  -                                collEl = new UndefinedElement(refAttr);
  -                                symbolTablePut(collEl);
  -                            }
  -                            symbolTablePut(new CollectionElement(qName, collEl, node, "[]"));
  +                        if (containedTE == null) {
  +                            containedTE = new UndefinedElement(containedQName);
  +                            symbolTablePut(containedTE);
                           }
  +                        symbolTablePut(new CollectionElement(qName, containedTE, node,
"[]"));
                       }
                   } else {
                       // Add a BaseType or Undefined Type/Element
  @@ -1305,8 +1298,9 @@
               
               // Check if this element is of the form:
               //    <element name="foo" type="tns:foo_type"/> 
  -            QName type = Utils.getNodeTypeRefQName(node, "type");
  -            if (type != null) {
  +            BooleanHolder forElement = new BooleanHolder();
  +            QName type = Utils.getTypeQName(node, forElement, false);
  +            if (type != null && !forElement.value) {
                   // If in fact we have such a type, go get the node that
                   // corresponds to THAT definition.
                   node = getTypeEntry(type, false).getNode();
  @@ -1715,7 +1709,7 @@
               entry.setIsReferenced(true);
               if (entry instanceof DefinedElement) {
                   BooleanHolder forElement = new BooleanHolder();
  -                QName referentName = Utils.getNodeTypeRefQName(node, forElement);
  +                QName referentName = Utils.getTypeQName(node, forElement, false);
                   if (referentName != null) {
                       TypeEntry referent = getTypeEntry(referentName, forElement.value);
                       if (referent != null) {
  @@ -1779,7 +1773,6 @@
               type = getElement(part.getElementName());
               if (type != null) {
                   setTypeReferences(type, doc, literal);
  -                //QName ref = Utils.getNodeTypeRefQName(type.getNode(), "type");
                   TypeEntry refType = type.getRefType();
                   if (refType != null) {
                     setTypeReferences(refType, doc, literal);
  
  
  
  1.18      +95 -50    xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/symbolTable/Utils.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Utils.java	28 Aug 2002 17:02:36 -0000	1.17
  +++ Utils.java	28 Aug 2002 22:53:17 -0000	1.18
  @@ -206,7 +206,7 @@
           
           // If this fails and the node has a ref, use the ref name.
           if (localName == null) {
  -            QName ref = getNodeTypeRefQName(node, "ref");
  +            QName ref = getTypeQNameFromAttr(node, "ref");
               if (ref != null) {
                   localName = ref.getLocalPart();
                   namespace = ref.getNamespaceURI();
  @@ -248,100 +248,130 @@
       }
   
       /**
  -     * XML nodes may have a type/ref attribute.
  -     * For example &lt.element name="foo" type="b:bar"&gt.
  -     * has the type attribute value "b:bar". 
  -     * This routine gets the QName of the type/ref attribute value.
  +     * An XML element or attribute node has several ways of 
  +     * identifying the type of the element or attribute:
  +     *  - use the type attribute to reference a complexType/simpleType
  +     *  - use the ref attribute to reference another element
  +     *  - use of an anonymous type (i.e. a nested type underneath itself)
  +     *  - a wsdl:part can use the element attribute.
  +     *  - an extension can use the base attribute.
        *
  -     * Note: If the "minOccurs" and "maxOccurs" are set such that the 
  +     * This routine returns a QName representing this "type".
  +     * The forElement value is also returned to indicate whether the 
  +     * QName represents an element (i.e. obtained using the ref attribute)
  +     * or a type.
  +     *
  +     * Other attributes affect the QName that is returned.
  +     * If the "minOccurs" and "maxOccurs" are set such that the 
        * type is a collection of "types", then an artificial qname is
        * returned to represent the collection.
        * 
  -     * If you want the QName for just the "type" without analyzing 
  -     * minOccurs/maxOccurs then use:
  -     *    getNodeTypeRefQName(node, "type")
  -     *
  -     * Note 2: The getNodeTypeRefQName routines also inspect the 
  -     *         "nillable" attribute and may return an alternate QName
  -     *         if nillable is true.  
  -     * 
        * @param node of the reference
        * @param forElement output parameter is set to true if QName is for an element
        *                   (i.e. ref= or element= attribute was used).
  +     * @param ignoreMaxOccurs indicates whether minOccurs/maxOccurs affects the QName
  +     * @return QName representing the type of this element
        */
  -    public static QName getNodeTypeRefQName(Node node, BooleanHolder forElement) {
  +    public static QName getTypeQName(Node node, BooleanHolder forElement, boolean ignoreMaxOccurs)
{
           if (node == null) return null;
           forElement.value = false; // Assume QName returned is for a type
   
  +        // Try getting the QName of the type attribute.
  +        // Note this also retrieves the type if an anonymous type is used.
  +        QName qName= getTypeQNameFromAttr(node, "type");
  +
  +        // If not successful, try using the ref attribute.
  +        if (qName == null) {
  +            forElement.value = true;
  +            qName = getTypeQNameFromAttr(node, "ref");
  +        }
  +
           // If the node has "type"/"ref" and "maxOccurs" then the type is really
           // a collection.  There is no qname in the wsdl which we can use to represent
           // the collection, so we need to invent one.
           // The local part of the qname is changed to <local>[minOccurs, maxOccurs]
           // The namespace uri is changed to the targetNamespace of this node
  -        QName qName= getNodeTypeRefQName(node, "type");
  -        if (qName == null) {
  -            forElement.value = true;
  -            qName = getNodeTypeRefQName(node, "ref");
  -        }
  -        if (qName != null) {
  -            String maxOccursValue = getAttribute(node, "maxOccurs");
  -            String minOccursValue = getAttribute(node, "minOccurs");
  -            if (maxOccursValue == null) {
  -                maxOccursValue = "1";
  -            }
  -            if (minOccursValue == null) {
  -                minOccursValue = "1";
  -            }
  -            if (minOccursValue.equals("0") && maxOccursValue.equals("1")) {
  -                // If we have a minoccurs="0"/maxoccurs="1", this is just
  -                // like a nillable single value, so treat it as such.
  -                qName = getNillableQName(qName);
  -            } else if (!maxOccursValue.equals("1") || !minOccursValue.equals("1")) {
  -                String localPart = qName.getLocalPart();
  -                localPart += "[" + maxOccursValue + "]";
  -                qName = new QName(qName.getNamespaceURI(), localPart);
  +        if (!ignoreMaxOccurs) {
  +            if (qName != null) {
  +                String maxOccursValue = getAttribute(node, "maxOccurs");
  +                String minOccursValue = getAttribute(node, "minOccurs");
  +                if (maxOccursValue == null) {
  +                    maxOccursValue = "1";
  +                }
  +                if (minOccursValue == null) {
  +                    minOccursValue = "1";
  +                }
  +                if (minOccursValue.equals("0") && maxOccursValue.equals("1")) {
  +                    // If we have a minoccurs="0"/maxoccurs="1", this is just
  +                    // like a nillable single value, so treat it as such.
  +                    qName = getNillableQName(qName);
  +                } else if (!maxOccursValue.equals("1") || !minOccursValue.equals("1"))
{
  +                    String localPart = qName.getLocalPart();
  +                    localPart += "[" + maxOccursValue + "]";
  +                    qName = new QName(qName.getNamespaceURI(), localPart);
  +                }
               }
           }
   
           // A WSDL Part uses the element attribute instead of the ref attribute
           if (qName == null) {
               forElement.value = true;
  -            qName = getNodeTypeRefQName(node, "element");
  +            qName = getTypeQNameFromAttr(node, "element");
           }
   
           // "base" references a "type"
           if (qName == null) {
               forElement.value = false;
  -            qName = getNodeTypeRefQName(node, "base");
  +            qName = getTypeQNameFromAttr(node, "base");
           }
           return qName;
       }
   
       /**
  -     * Obtain the QName of the type/ref using the indicated attribute name.
  -     * For example, the "type" attribute in an XML enumeration struct is the 
  -     * "base" attribute. 
  -     * If the "type" attribute is requested, the "nillable" attribute is 
  -     * also inspected to see if an alternate qname should be returned.
  +     * Gets the QName of the type of the node via the specified attribute
  +     * name.
  +     *
  +     * If "type", the QName represented by the type attribute's value is 
  +     * returned.  If the type attribute is not set, the anonymous type
  +     * or anyType is returned if no other type information is available.
  +     * Note that the QName returned in these cases is affected by
  +     * the presence of the nillable attribute.
  +     *
  +     * If "ref", the QName represented by the ref attribute's value is 
  +     * returned.
  +     * 
  +     * If "base" or "element", the QName represented by the base/element
  +     * attribute's value is returned.
        *
        * @param node in the dom
        * @param typeAttrName (type, base, element, ref)
        */
  -    public static QName getNodeTypeRefQName(Node node, String typeAttrName) {
  +    private static QName getTypeQNameFromAttr(Node node, String typeAttrName) {
           if (node == null) {
               return null;
           }
  +        // Get the raw prefixed value
           String prefixedName = getAttribute(node, typeAttrName);
   
  -        // The type attribute defaults to xsd:anyType if there
  -        // are no other conflicting attributes and no anonymous type.
  +        // If "type" was specified but there is no type attribute,
  +        // check for an anonymous type.  If no anonymous type
  +        // then the type is anyType.
           if (prefixedName == null &&
               typeAttrName.equals("type")) {
               if (getAttribute(node, "ref") == null &&
                   getAttribute(node, "base") == null && 
  -                getAttribute(node, "element") == null &&
  -                SchemaUtils.getElementAnonQName(node) == null &&
  -                SchemaUtils.getAttributeAnonQName(node) == null) {
  +                getAttribute(node, "element") == null) {
  +                
  +                // Try getting the anonymous qname
  +                QName anonQName = SchemaUtils.getElementAnonQName(node);
  +                if (anonQName == null) {
  +                    anonQName = SchemaUtils.getAttributeAnonQName(node);
  +                }
  +                if (anonQName != null) {
  +                    return anonQName;
  +                }
  +
  +                // Try returning anyType
                   QName nodeName = getNodeQName(node);
                   if (nodeName != null &&
                       Constants.isSchemaXSD(nodeName.getNamespaceURI()) &&
  @@ -502,6 +532,15 @@
               }
           }
           
  +        // Process referenced types
  +        if (type.getRefType() != null &&
  +            !types.contains(type.getRefType())) {
  +            types.add(type.getRefType());
  +            getNestedTypes(type.getRefType(), types, symbolTable, derivedFlag);
  +        }
  +
  +        /* Anonymous processing and should be automatically handled by the 
  +           reference processing above
           // Get the anonymous type of the element
           QName anonQName = SchemaUtils.getElementAnonQName(node);
           if (anonQName != null) {
  @@ -519,6 +558,8 @@
                   types.add(anonType);
               }
           }
  +        */
  +
           // Process extended types
           TypeEntry extendType = SchemaUtils.getComplexElementExtensionBase(node, symbolTable);
           if (extendType != null) {
  @@ -528,6 +569,8 @@
               }
           }
   
  +        /* Array component processing should be automatically handled by the
  +           reference processing above.
           // Process array components
           QName componentQName = SchemaUtils.getArrayComponentQName(node, new IntHolder(0));
           TypeEntry componentType = symbolTable.getType(componentQName);
  @@ -540,6 +583,8 @@
                   getNestedTypes(componentType, types, symbolTable, derivedFlag);
               }
           }
  +        */
  +
       } // getNestedTypes
   
       /**
  
  
  
  1.20      +56 -30    xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java
  
  Index: JavaGeneratorFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaGeneratorFactory.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JavaGeneratorFactory.java	23 Aug 2002 21:50:48 -0000	1.19
  +++ JavaGeneratorFactory.java	28 Aug 2002 22:53:17 -0000	1.20
  @@ -71,6 +71,7 @@
   import javax.wsdl.OperationType;
   import javax.wsdl.PortType;
   import javax.xml.namespace.QName;
  +import javax.xml.rpc.holders.BooleanHolder;
   import javax.wsdl.Service;
   
   import org.apache.axis.encoding.TypeMapping;
  @@ -356,38 +357,60 @@
                           dims += tEntry.getDimensions();
                           refType = tEntry.getRefType();
                       }
  -                    
  -                    // Get the QName to javify
  -                    QName typeQName = tEntry.getQName();
  -                    if ((typeQName.getLocalPart().indexOf(SymbolTable.ANON_TOKEN) >=
0) &&
  -                            (tEntry.getName() == null)) {
  -                        // This is an anonymous type name.
  -                        // Axis uses '>' as a nesting token to generate
  -                        // unique qnames for anonymous types.
  -                        // Only consider the localName after the last '>' when
  -                        // generating the java name
  -                        String localName = typeQName.getLocalPart();
  -                        localName = 
  -                            localName.substring(
  -                                localName.lastIndexOf(SymbolTable.ANON_TOKEN)+1);
  -                        typeQName = new QName(typeQName.getNamespaceURI(), localName);
  -                        // If there is already an existing type, there will be a 
  -                        // collision.  If there is an existing anon type, there will be
a 
  -                        // collision.  In both cases, the java type name should be mangled.
  -                        symbolTable.getType(typeQName);
  -                        if (anonQNames.get(typeQName) != null) {
  -                            localName += "Type" + uniqueNum++;
  -                            typeQName = new QName(typeQName.getNamespaceURI(), localName);
  +
  +
  +                    // Need to javify the ref'd TypeEntry if it was not
  +                    // already processed
  +                    if (tEntry.getName() == null) {
  +                        // Get the QName of the ref'd TypeEntry, which
  +                        // is will be used to javify the name
  +                        QName typeQName = tEntry.getQName();
  +                        if ((typeQName.getLocalPart().
  +                             indexOf(SymbolTable.ANON_TOKEN) < 0)) {
  +                            // Normal Case: The ref'd type is not anonymous
  +                            // Simply construct the java name from
  +                            // the qName
  +                            tEntry.setName(emitter.getJavaName(typeQName));
  +                        } else {
  +                            // This is an anonymous type name.
  +                            // Axis uses '>' as a nesting token to generate
  +                            // unique qnames for anonymous types.
  +                            // Only consider the localName after the last '>' 
  +                            // when generating the java name
  +                            String localName = typeQName.getLocalPart();
  +                            localName = 
  +                                localName.substring(
  +                                    localName.lastIndexOf(
  +                                        SymbolTable.ANON_TOKEN)+1);
  +                            typeQName = new QName(typeQName.getNamespaceURI(), 
  +                                                  localName);
  +                            // If there is already an existing type,
  +                            // there will be a collision.  
  +                            // If there is an existing anon type, 
  +                            // there will be a  collision.  
  +                            // In both cases, mangle the name.
  +                            symbolTable.getType(typeQName);
  +                            if (anonQNames.get(typeQName) != null) {
  +                                localName += "Type" + uniqueNum++;
  +                                typeQName = 
  +                                    new QName(typeQName.getNamespaceURI(),
  +                                              localName);
  +                            } 
  +                            anonQNames.put(typeQName, typeQName);
  +
  +                            // Now set the name with the constructed qname
  +                            tEntry.setName(emitter.getJavaName(typeQName));
                           } 
  -                        anonQNames.put(typeQName, typeQName);
  -                        tEntry.setName(emitter.getJavaName(typeQName) + dims);
                       }
  -                    entry.setName(emitter.getJavaName(typeQName) + dims);
  +                    // Set the entry with the same name as the ref'd entry
  +                    // but add the appropriate amount of dimensions
  +                    entry.setName(tEntry.getName() + dims);
                   }
   
  -                // If it is not a type, then use this entry's QName to generate its name.
  +                // If it is not a type, then use this entry's QName to 
  +                // generate its name.
                   else {
  -                    entry.setName(emitter.getJavaName(entry.getQName()));
  +                    entry.setName(emitter.getJavaName(entry.getQName()));   
                   }
               }
           }
  @@ -575,7 +598,7 @@
                   boolean resolve = true;
                   // Common Special Case:
                   // If a Type and Element have the same QName, and the Element
  -                // uses type= to reference the Type, then they are the same class so 
  +                // references the Type, then they are the same class so 
                   // don't bother mangling.
                   if (v.size() == 2 &&
                       ((v.elementAt(0) instanceof Element &&
  @@ -588,8 +611,11 @@
                       } else {
                           e = (Element)v.elementAt(1);
                       }
  -                    QName eType = Utils.getNodeTypeRefQName(e.getNode(), "type");
  -                    if (eType != null && eType.equals(e.getQName()))
  +                    BooleanHolder forElement = new BooleanHolder();
  +                    QName eType = Utils.getTypeQName(e.getNode(), forElement, false);
  +                    if (eType != null && 
  +                        eType.equals(e.getQName()) &&
  +                        !forElement.value)
                           resolve = false;
                   }
   
  
  
  
  1.89      +2 -1      xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- JavaStubWriter.java	26 Aug 2002 13:10:22 -0000	1.88
  +++ JavaStubWriter.java	28 Aug 2002 22:53:17 -0000	1.89
  @@ -160,7 +160,8 @@
               writeSerializationDecls(pw, hasMIME, binding.getQName().getNamespaceURI());
               Iterator it = types.iterator();
               while (it.hasNext()) {
  -                writeSerializationInit(pw, (TypeEntry) it.next());
  +                TypeEntry te = (TypeEntry) it.next();
  +                writeSerializationInit(pw, te);
               }
           }
   
  
  
  
  1.54      +1 -1      xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- Utils.java	26 Aug 2002 21:15:54 -0000	1.53
  +++ Utils.java	28 Aug 2002 22:53:17 -0000	1.54
  @@ -288,7 +288,7 @@
               // The base type must be a built-in type, and not boolean
               TypeEntry baseEType = null;
               if (restrictionNode != null) {
  -                QName baseType = Utils.getNodeTypeRefQName(restrictionNode, "base");
  +                QName baseType = Utils.getTypeQName(restrictionNode, new BooleanHolder(),
false);
                   baseEType = symbolTable.getType(baseType);
                   if (baseEType != null) {
                       String javaName = baseEType.getName();
  
  
  
  1.39      +12 -0     xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl
  
  Index: ComprehensiveTypes.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- ComprehensiveTypes.wsdl	27 Aug 2002 20:38:13 -0000	1.38
  +++ ComprehensiveTypes.wsdl	28 Aug 2002 22:53:17 -0000	1.39
  @@ -108,9 +108,21 @@
               <xsd:element name="optArray" minOccurs="0" maxOccurs="1" type="typens:array"
/>
               <xsd:element name="byteArray" type="typens:array_of_base64" />
               <xsd:element name="parm" type="typens:StringParameter" />
  +
  +            <!-- Test for types that are similarly named to common java lang classes
-->
               <xsd:element name="myObject" type="typens:Object" />
               <xsd:element name="myString" type="typens:String" />
               <xsd:element name="myClass" type="typens:Class" />
  +
  +            <!-- Test anonymous type with an element that has maxOccurs -->
  +            <xsd:element name="logEntry" minOccurs="0" maxOccurs="unbounded">
  +              <xsd:complexType>
  +                <xsd:sequence>
  +                   <xsd:element name="name" type="xsd:string"/>
  +                   <xsd:element name="value" type="xsd:string"/>
  +                </xsd:sequence>
  +              </xsd:complexType>
  +            </xsd:element>
             </xsd:all>
             <xsd:attribute name="attr" type="typens:enum" />
             <xsd:attribute name="parmAttr" type="typens:StringParameter" />
  
  
  

Mime
View raw message