castor

Schema with imported simpletypes generates incorrect Java code

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.5
  • Fix Version/s: 1.1 M3
  • Component/s: XML code generator
  • Labels:
    None
  • Number of attachments :
    5

Description

A schema which defines a simpletype using a restriction-base from an imported schema generates incorrect Java-code.

In the attached schema look at the LanguageCode, which is of a simpletype defined in the same schema. this type is based on a LanguageCodeType from an imported schema.

<xsd:complexType name="BusinessObjectDocumentType">
<xsd:attribute name="languageCode" type="LanguageCodeType" use="optional" default="en-US"> </xsd:attribute>
</xsd:complexType>

<xsd:simpleType name="LanguageCodeType">
<xsd:restriction base="qdt:LanguageCodeType"/>
</xsd:simpleType>

This generated javacode looks like:
private java.lang.Object _languageCode = new java.lang.Object("en-US");

  1. patch.c1839.20071217.txt
    17/Jan/07 5:51 AM
    1.0 kB
    Werner Guttmann
  2. patch.c1839.tests.20070118.txt
    18/Jan/07 2:32 AM
    54 kB
    Werner Guttmann

Activity

Hide
Daniel Nilsson added a comment -

A typo was entered above.
The typename should be LanguageCodeTypeE not LanguageCodeType. The trailing E is to distinguish it from the imported typename.

The type SystemEnvironmentCodeContentType also generated incorrect code. (interesting with this is that the name is the same as in the imported typename)

Also the incorrect code can be found in BusinessObjectDocumentType.java

Show
Daniel Nilsson added a comment - A typo was entered above. The typename should be LanguageCodeTypeE not LanguageCodeType. The trailing E is to distinguish it from the imported typename. The type SystemEnvironmentCodeContentType also generated incorrect code. (interesting with this is that the name is the same as in the imported typename) Also the incorrect code can be found in BusinessObjectDocumentType.java
Hide
Werner Guttmann added a comment -

Daniel, would you please be able to attach a sample XML document that you'd want to successfully unmarhal against the classes generated ?

Show
Werner Guttmann added a comment - Daniel, would you please be able to attach a sample XML document that you'd want to successfully unmarhal against the classes generated ?
Hide
Werner Guttmann added a comment -

Okay, after some serious debugging, here's an early analysis. Right now, TypeConversion .convertType(Simpletype ....) perfectly traverses the inheritance hierarchy for simple restrictions. Unfortunately, the same does not apply for inheritance hierarchies if UNIONs are involved. I think I have a patch read (which I will attach in a second), but let me try to test a few more things. Strangely enough, all tests finish.

In other words, whether a simple type is imported or not, does not make a difference. It's just that the code is incomplete with regards to handling 'union hierarchies'.

Show
Werner Guttmann added a comment - Okay, after some serious debugging, here's an early analysis. Right now, TypeConversion .convertType(Simpletype ....) perfectly traverses the inheritance hierarchy for simple restrictions. Unfortunately, the same does not apply for inheritance hierarchies if UNIONs are involved. I think I have a patch read (which I will attach in a second), but let me try to test a few more things. Strangely enough, all tests finish. In other words, whether a simple type is imported or not, does not make a difference. It's just that the code is incomplete with regards to handling 'union hierarchies'.
Hide
Werner Guttmann added a comment -

Initial patch for review. As already mentioned, all CTF tests complete without any hiccups .....

Show
Werner Guttmann added a comment - Initial patch for review. As already mentioned, all CTF tests complete without any hiccups .....
Hide
Edward Kuns added a comment -

Looks good to me.

Show
Edward Kuns added a comment - Looks good to me.
Hide
Werner Guttmann added a comment -

Daniel, any objections against using the sample XML schemas to enhance our test suite ?

Show
Werner Guttmann added a comment - Daniel, any objections against using the sample XML schemas to enhance our test suite ?
Hide
Daniel Nilsson added a comment -

Hi!
You are the king Werner!
I don't have any objections that you include the sample XML. And the OAGI schemas should be free so there shouldn't be any problems with thoose either. The more tests and scenarions the better.

Show
Daniel Nilsson added a comment - Hi! You are the king Werner! I don't have any objections that you include the sample XML. And the OAGI schemas should be free so there shouldn't be any problems with thoose either. The more tests and scenarions the better.
Hide
Werner Guttmann added a comment -

Thank you so much for the compliments. I'd still need a (valid) sample document that matches the XML schemas you've attached so that I can complete the test case successfully. The reason why I asked 'for permission' is simple: it could have been that there's custom extension of yours that you might not like to see 'exposed' as part of an open source framework.

Show
Werner Guttmann added a comment - Thank you so much for the compliments. I'd still need a (valid) sample document that matches the XML schemas you've attached so that I can complete the test case successfully. The reason why I asked 'for permission' is simple: it could have been that there's custom extension of yours that you might not like to see 'exposed' as part of an open source framework.
Hide
Werner Guttmann added a comment -

Initial patch for review. I'd still like to use a 'real' XML document rather than a knocked up ..... .

Show
Werner Guttmann added a comment - Initial patch for review. I'd still like to use a 'real' XML document rather than a knocked up ..... .
Hide
Werner Guttmann added a comment -

Daniel ?

Show
Werner Guttmann added a comment - Daniel ?
Hide
Daniel Nilsson added a comment -

Sorry for the delay.
Attached is an initial workinprogress of the schemas I am to create the sources for I created a sample document with Alatova XML spy which

There is anyhow a part which looks like this:

Show
Daniel Nilsson added a comment - Sorry for the delay. Attached is an initial workinprogress of the schemas I am to create the sources for I created a sample document with Alatova XML spy which There is anyhow a part which looks like this:
Hide
Daniel Nilsson added a comment -

hmm, and that is what happens when you accedently hit Enter...

Ok, to complete the previous message:

I created a sample xml-document with XmlSpy from the xsd since I don't have any other samples at this moment.
There is also a section in the xsd looking like:
<xsd:complexType name="UserAreaType" block="restriction">
<xsd:sequence>
<xsd:any namespace="##any" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
which I havn't tried with castor. If it doesnät work let me know and I can strip that part out from the sample.

Show
Daniel Nilsson added a comment - hmm, and that is what happens when you accedently hit Enter... Ok, to complete the previous message: I created a sample xml-document with XmlSpy from the xsd since I don't have any other samples at this moment. There is also a section in the xsd looking like: <xsd:complexType name="UserAreaType" block="restriction"> <xsd:sequence> <xsd:any namespace="##any" processContents="strict" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> which I havn't tried with castor. If it doesnät work let me know and I can strip that part out from the sample.
Hide
Daniel Nilsson added a comment -

removed some unnecassary binding-files

Show
Daniel Nilsson added a comment - removed some unnecassary binding-files
Hide
Werner Guttmann added a comment -

Daniel, with the last archive you attached, code generation completes with errors. Any idea why ?

Show
Werner Guttmann added a comment - Daniel, with the last archive you attached, code generation completes with errors. Any idea why ?
Hide
Werner Guttmann added a comment -

Actually, found the problem. Just committed the new CTF test case (based upon your sample), and included a small patch to JDescriptorClass to fix an issue related to incorrect import statements for descriptor classes that extend another descriptor, and not XMLClassDescriptorImpl.

Show
Werner Guttmann added a comment - Actually, found the problem. Just committed the new CTF test case (based upon your sample), and included a small patch to JDescriptorClass to fix an issue related to incorrect import statements for descriptor classes that extend another descriptor, and not XMLClassDescriptorImpl.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
4h
Original Estimate - 4 hours
Remaining:
2h 10m
Time Spent - 1 hour, 50 minutes Remaining Estimate - 2 hours, 10 minutes
Logged:
1h 50m
Time Spent - 1 hour, 50 minutes Remaining Estimate - 2 hours, 10 minutes