Title: RE: Includes

Russell,

Thank you for you reply. To test includes you just need to move definition to separate file within the same namespace and add include statement in the referencing one. But anyway I combined my testcase in one zip archive and attaching it to this memo. I also included file for mapping namespace to package (otherwise names could clash, because they are not unique) and my simple batch file for running this example with and without include. This example also covers my previous problem with multiple imports, which I posted before. And even more...

Yes, I have some other concerns I want to discuss.

1. Complex types with restriction 

When I am using type with restriction, like

  <complexType name="CUSTOMER_HKEYFieldsType">
    <complexContent>
      <restriction base="tns:AllFieldsType">
        <all>
          <element name="CUSTID" type="string" minOccurs="0"/>
          <element name="COMPNUM" type="string" minOccurs="0"/>
          <element name="ARIGLBNM" type="decimal" minOccurs="0"/>
        </all>
      </restriction>
    </complexContent>
  </complexType>

WSDL2Java generates empty Java class. When I correct this definition to be like

  <complexType name="CUSTOMER_HKEYFieldsType">
        <all>
          <element name="CUSTID" type="string" minOccurs="0"/>
          <element name="COMPNUM" type="string" minOccurs="0"/>
          <element name="ARIGLBNM" type="decimal" minOccurs="0"/>
        </all>
  </complexType>
it generates correct code with 3 private fields and get/set methods, but there is nothing wrong with the original syntax. It just says that these are the same 3 fields as in tns:AllFieldsType, but only these 3. (You could fine this and other like samples in ciarctl\aritem.xsd in the attached zip)

Another case where empty code is generated:
    <complexType name="ComplexDateTime">
     <restriction base="dateTime">
     </restriction>
    </complexType>

I tried to change restriction to extension:

    <complexType name="ComplexDateType">
      <extension base="date">
     </extension>
    </complexType>
and expected to get class that extends java.util.Date, but it's not. BTW is this syntax correct? Because when I added <complexContent> tag

    <complexType name="ComplexDateType">
    <complexContent>
     <extension base="date">
     </extension>
     </complexContent>
    </complexType>

it really extended Date class.

2. Simple types with restriction to xsd:date

For the simple type

 <simpleType name="DateType">
   <restriction base="xsd:date">
   </restriction>
  </simpleType>

code generated:

public class DateType implements java.io.Serializable, org.apache.axis.encoding.SimpleType {
    private java.util.Date value;

    public DateType() {
    }

    public java.util.Date getValue() {
        return value;
    }

    public void setValue(java.util.Date value) {
        this.value = value;
    }

    public DateType(java.util.Date value) {
        this.value = value;
    }

    // Simple Types must have a String constructor
    public DateType(java.lang.String value) {
        this.value = new java.util.Date(value);
    }
... etc

}

Nothing wrong is here, except that that in a String constructor Date(String) method is deprecated and compiler produces deprecated warnings.

May be we should generate instead of
                this.value = new java.util.Date(value);
something like this

        try{
          this.value = (java.text.DateFormat.getDateTimeInstance()).parse(value);
        }
        catch (java.text.ParseException e){
          this.value = new java.util.Date();  // ??? or null???
        }
3. Simple types restricted to xsd:dateTime

  <simpleType name="DateTime">
   <restriction base="xsd:dateTime">
   </restriction>
  </simpleType>

Here situation gets even worse, because it is mapped to java.util.Calendar class and String constructor has code

 this.value = new java.util.Calendar(value);

which does not compile, because Calendar class does not have public constructor.

My suggestion is to generate for Calendar fields something like

    java.util.Calendar cal = java.util.Calendar.getInstance();
        try{
          java.util.Date dt = java.text.DateFormat.getDateTimeInstance().parse(value);
          cal.setTime(dt);
          this.value = cal;
        }
        catch (java.text.ParseException e){
          this.value = cal;  // ??? current or null??? or rethrow??
          }


Thanks

Michael



-----Original Message-----
From: Russell Butek [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 10:40 AM
To: [EMAIL PROTECTED]
Subject: Re: Includes


AXIS probably doesn't yet support xml include.  I would have hoped that we
would have gotten it for free using xerces, but perhaps not.  Could you
send us an example that we can test?

We DO support import but, as you pointed out in a previous note, it falls
apart in certain cases.  As I said, I'll look at the import problem as soon
as I get the chance.

Russell Butek
[EMAIL PROTECTED]


"Sapozhnikov, Michael" <[EMAIL PROTECTED]> on 05/29/2002 09:10:39 AM

Please respond to [EMAIL PROTECTED]

To:    "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:
Subject:    Includes





Hi,
We have elaborate set of XSDs generated by our own tool. Some of them
"live" in the same namespace,
but they don't have knowledge of content of each other except the file
name.
So the most natural way to connect them is not copy and paste one into
another, but using <include>
statement in one XSD file to get access to definitions in another one in
the same namespace.

Unfortunately, I am getting exception that type in included document is
referenced but not defined.

So my question is: Are includes supported in current AXIS implementation,
are any plans to support them
or I just do something wrong?

Thanks,

Michael


 

Attachment: schemas.zip
Description: Binary data

Reply via email to