axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ravi Kumar <rku...@borland.com>
Subject TypeFactory, namespace and packages
Date Mon, 08 Oct 2001 19:29:36 GMT
Below is the types section from a WSDL. Notice two schema nodes with
with same complex type names (phone) but with different targetNameSpaces
(nameSpace1 and nameSpace2).

There should be no name conflicts in the generated code, as they both
are scoped to belong in different packages (based on targetNameSpace).

But the TypeFactory implementation ignores the namespace to package
mapping completely as it doesn't initialize the mapNamespaceToPackage

To fix this (if it is ineed a bug), a few changes need to be made

Let me know, I can submit a patch

Rgds
Ravi

Change1
---------
TypeFactory.getJavaName() {
  ....
  map(qName.getNameSpaceURI);

  ...
}

TypeFacory void map (String namespace) {
      if (mapNamespaceToPackage.get(nameSpace) == null) {
        mapNamespaceToPackage.put(namespace,
Utils.generatePackageName(nameSpace);
      }
}

Change 2
----------
Move the Emitter->makePackageName logic to Utils.generatePackegeName

Changes 3
----------
Emitter->writeXXXType needs to pass the
    private PrintWriter printWriter(String name, String packageName)
throws IOException
    {
        .....
        String pkgDirName = packageDirName;
        if (packageName == null) {
          pkgDirName = packageName.replace('.', '/');
        }
       ....
    }

change 4
---------
Emitter should call
TypeFactory.map(targetNameSpace, packageName)
with either the user given or auto generated packageName

  <types>
    <xsd:schema targetNamespace="urn:namespace1"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:complexType name="phone">
        <xsd:all>
            <xsd:element name="areaCode" type="xsd:int"/>
        </xsd:all>
      </xsd:complexType>
    </xsd:schema>

    <xsd:schema targetNamespace="urn:namespace2"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:complexType name="phone">
        <xsd:all>
            <xsd:element name="areaCode" type="xsd:int"/>
        </xsd:all>
      </xsd:complexType>
    </xsd:schema>
  </types>




Mime
View raw message