You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sc...@apache.org on 2002/08/28 19:02:36 UTC

cvs commit: xml-axis/java/test/wsdl/refattr refattr.wsdl

scheu       2002/08/28 10:02:36

  Modified:    java/src/org/apache/axis/wsdl/symbolTable SchemaUtils.java
                        SymbolTable.java Utils.java
               java/test/wsdl/refattr refattr.wsdl
  Log:
  Fix for a WSDL2Java problem reported by Damian Hagge (IBM).
  An element that had both ref= and maxOccurs= was not being
  marked as referenced.  This resulted missing java classes.
  
  Fixed the problem and added the case to the refattr test.
  
  Revision  Changes    Path
  1.14      +33 -23    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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SchemaUtils.java	24 Aug 2002 01:25:19 -0000	1.13
  +++ SchemaUtils.java	28 Aug 2002 17:02:36 -0000	1.14
  @@ -340,6 +340,17 @@
           QName nodeName = Utils.getNodeNameQName(elementNode);
           BooleanHolder forElement = new BooleanHolder();
   
  +        // 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);
  +
  +        if (nodeType == null) {
  +            nodeType = getElementAnonQName(elementNode);            
  +            forElement.value = false;
  +        }        
  +        TypeEntry type = (TypeEntry)symbolTable.getTypeEntry(nodeType, 
  +                                                             forElement.value);
  +
           // An element inside a complex type is either qualified or unqualified.
           // If the ref= attribute is used, the name of the ref'd element is used
           // (which must be a root element).  If the ref= attribute is not
  @@ -363,15 +374,6 @@
               }
           }
   
  -        // 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);
  -        if (nodeType == null) {
  -            nodeType = getElementAnonQName(elementNode);            
  -            forElement.value = false;
  -        }        
  -        TypeEntry type = (TypeEntry)symbolTable.getTypeEntry(nodeType, 
  -                                                             forElement.value);
           if (type != null) {
               ElementDecl elem = new ElementDecl(type, nodeName);
               String minOccurs = Utils.getAttribute(elementNode, "minOccurs");
  @@ -718,23 +720,27 @@
        * @param dims is the output value that contains the number of dimensions if return is not null
        * @return QName or null
        */
  -    public static QName getArrayElementQName(Node node, IntHolder dims) {
  +    public static QName getArrayComponentQName(Node node, IntHolder dims) {
           dims.value = 1;  // assume 1 dimension
  -        QName qName = getCollectionElementQName(node);
  +        QName qName = getCollectionComponentQName(node);
           if (qName == null) {
  -            qName = getArrayElementQName_JAXRPC(node, dims);
  +            qName = getArrayComponentQName_JAXRPC(node, dims);
           }
           return qName;
       }
   
       /**
  -     * If the specified node represents an element that refernces a collection
  -     * then return the qname repesenting the element type of the collection.
  +     * If the specified node represents an element that references a collection
  +     * then return the qname repesenting the component of the collection.
        *
        *  <xsd:element name="alias" type="xsd:string" maxOccurs="unbounded"/>
  -     *
  +     *    returns qname for"xsd:string"
  +     *  <xsd:element ref="alias"  maxOccurs="unbounded"/>
  +     *    returns qname for "alias"
  +     * @param node is the Node
  +     * @return QName of the compoent of the collection
        */
  -    private static QName getCollectionElementQName(Node node) {
  +    private static QName getCollectionComponentQName(Node node) {
           if (node == null) {
               return null;
           }
  @@ -745,15 +751,19 @@
               nodeKind.getLocalPart().equals("element") &&
               Constants.isSchemaXSD(nodeKind.getNamespaceURI())) {
   
  -            // Get the qName of just the type.
  +            // 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 element type).
  -            QName justTypeQName = Utils.getNodeTypeRefQName(node, "type");
  -            if (justTypeQName != null) {
  +            // 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");
  +            }
  +
  +            if (componentQName != null) {
                   QName fullTypeQName = Utils.getNodeTypeRefQName(node, new BooleanHolder());
  -                if (justTypeQName != fullTypeQName)
  -                    return justTypeQName;
  +                if (componentQName != fullTypeQName)
  +                    return componentQName;
               }
           }
           return null;
  @@ -788,7 +798,7 @@
        *</xsd:complexType>
        *
        */
  -    private static QName getArrayElementQName_JAXRPC(Node node, IntHolder dims) {
  +    private static QName getArrayComponentQName_JAXRPC(Node node, IntHolder dims) {
           dims.value = 0;  // Assume 0
           if (node == null) {
               return null;
  
  
  
  1.27      +1 -1      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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- SymbolTable.java	23 Aug 2002 21:50:48 -0000	1.26
  +++ SymbolTable.java	28 Aug 2002 17:02:36 -0000	1.27
  @@ -781,7 +781,7 @@
                   // See if this is an array or simple type definition.
                   IntHolder numDims = new IntHolder();
                   numDims.value = 0;
  -                QName arrayEQName = SchemaUtils.getArrayElementQName(node, numDims);
  +                QName arrayEQName = SchemaUtils.getArrayComponentQName(node, numDims);
   
                   if (arrayEQName != null) {
                       // Get the TypeEntry for the array element type
  
  
  
  1.17      +10 -7     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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Utils.java	15 Aug 2002 21:27:47 -0000	1.16
  +++ Utils.java	28 Aug 2002 17:02:36 -0000	1.17
  @@ -528,13 +528,16 @@
               }
           }
   
  -        // Process array element types
  -        QName elementQName = SchemaUtils.getArrayElementQName(node, new IntHolder(0));
  -        TypeEntry elementType = symbolTable.getType(elementQName);
  -        if (elementType != null) {
  -            if (!types.contains(elementType)) {
  -                types.add(elementType);
  -                getNestedTypes(elementType, types, symbolTable, derivedFlag);
  +        // Process array components
  +        QName componentQName = SchemaUtils.getArrayComponentQName(node, new IntHolder(0));
  +        TypeEntry componentType = symbolTable.getType(componentQName);
  +        if (componentType == null) {
  +            componentType = symbolTable.getElement(componentQName);
  +        }
  +        if (componentType != null) {
  +            if (!types.contains(componentType)) {
  +                types.add(componentType);
  +                getNestedTypes(componentType, types, symbolTable, derivedFlag);
               }
           }
       } // getNestedTypes
  
  
  
  1.5       +10 -0     xml-axis/java/test/wsdl/refattr/refattr.wsdl
  
  Index: refattr.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/refattr/refattr.wsdl,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- refattr.wsdl	13 Mar 2002 15:19:27 -0000	1.4
  +++ refattr.wsdl	28 Aug 2002 17:02:36 -0000	1.5
  @@ -112,9 +112,19 @@
             <xsd:element ref="typens:mangle"/>
             <!-- The following better be Mangle_Type[], not Mangle[] -->
             <xsd:element name="mangle2" type="typens:mangle" maxOccurs="unbounded" />
  +
  +          <!-- Make sure WSDL2Java properly sets the option element as referenced -->
  +          <xsd:element ref="typens:option" minOccurs="1" maxOccurs="unbounded" />
           </xsd:all>
         </xsd:complexType>
   
  +      <xsd:element name="option" type="typens:optionType"/>
  +      <xsd:complexType name="optionType">
  +        <xsd:sequence>
  +          <xsd:element name="name"  type="xsd:string" />
  +          <xsd:element name="value" type="xsd:string" />
  +        </xsd:sequence>
  +      </xsd:complexType>
       </xsd:schema>
     </types>