You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2004/06/03 16:01:33 UTC

cvs commit: ws-axis/java/src/org/apache/axis/wsdl/fromJava Types.java

dims        2004/06/03 07:01:33

  Modified:    java/src/org/apache/axis/wsdl/fromJava Types.java
  Log:
  Fix for AXIS-526 - WSDL generated by Axis does not properly generate references to schemas
  from Andrei.Iltchenko@nl.compuware.com
  
  Revision  Changes    Path
  1.94      +51 -10    ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- Types.java	8 Apr 2004 13:09:07 -0000	1.93
  +++ Types.java	3 Jun 2004 14:01:33 -0000	1.94
  @@ -1475,24 +1475,65 @@
       }
   
       /**
  -     * Inserts the type fragment into the given wsdl document
  -     *
  +     * Inserts the type fragment into the given wsdl document and ensures
  +     * that definitions from each embedded schema are allowed to reference
  +     * schema components from the other sibling schemas.
        * @param doc
        */
       public void insertTypesFragment(Document doc) {
   
           updateNamespaces();
   
  -        if (wsdlTypesElem != null) {
  +        if (wsdlTypesElem == null) 
  +            return;
   
  -            // Import the wsdlTypesElement into the doc.
  -            org.w3c.dom.Node node = doc.importNode(wsdlTypesElem, true);
  +        // Make sure that definitions from each embedded schema are allowed
  +        // to reference schema components from the other sibling schemas.
  +        Element schemaElem = null;
  +        String tns = null;
  +        NodeList nl = wsdlTypesElem.getChildNodes();
  +        for (int i = 0; i < nl.getLength(); i++) {
  +            NamedNodeMap attrs = nl.item(i).getAttributes();
  +            if (attrs == null) continue; // Should never happen.
  +            for (int n = 0; n < attrs.getLength(); n++) {
  +                Attr a = (Attr) attrs.item(n);
  +                if (a.getName().equals("targetNamespace")) {
  +                    tns = a.getValue();
  +                    schemaElem = (Element) nl.item(i);
  +                    break;
  +                }
  +            }
   
  -            // Insert the imported element at the beginning of the document
  -            doc.getDocumentElement().insertBefore(
  -                    node, doc.getDocumentElement().getFirstChild());
  -        }
  -    }
  +            // Ignore what appears to be a not namespace-qualified
  +            // schema definition.
  +            if (tns != null && !"".equals(tns.trim())) {
  +                // By now we know that an import element might be necessary
  +                // for some sibling schemas. However, in the absence of
  +                // a symbol table proper, the best we can do is add one
  +                // for each sibling schema.
  +                Iterator it = schemaTypes.keySet().iterator();
  +                String otherTns;
  +                Element importElem;
  +                while (it.hasNext()) {
  +                    if (!tns.equals(otherTns = (String) it.next())) {
  +                        importElem = docHolder.createElement("import");
  +                        importElem.setAttribute("namespace", otherTns);
  +                        schemaElem.insertBefore(importElem,
  +                                schemaElem.getFirstChild());
  +                    }
  +                }
  +            }
  +            schemaElem = null;
  +            tns = null;
  +        }  
  +
  +        // Import the wsdlTypesElement into the doc.
  +        org.w3c.dom.Node node = doc.importNode(wsdlTypesElem, true);
  +        // Insert the imported element at the beginning of the document
  +        doc.getDocumentElement().
  +                insertBefore(node,
  +                        doc.getDocumentElement().getFirstChild());
  +    }  
   
       /**
        * Return the list of classes that we should not emit WSDL for.