Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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");
-
Hide
- castor_example.zip
- 23/Jan/07 3:56 PM
- 14 kB
- Daniel Nilsson
-
- castor_example/sample.xml 5 kB
- castor_example/SyncItem.xsd 20 kB
- castor_example/SyncItem.xsd.binding 2 kB
- castor_example/.../CodeLists.xsd 4 kB
- castor_example/.../CodeList_CurrencyCode_ISO_7_04.xsd 0.9 kB
- castor_example/.../CodeList_MIMEMediaTypeCode_IANA_7_04.xsd 0.9 kB
- castor_example/.../CodeList_LanguageCode_ISO_7_04.xsd 1 kB
- castor_example/.../QualifiedDataTypes.xsd 7 kB
- castor_example/.../CodeList_UnitCode_UNECE_7_04.xsd 0.9 kB
- castor_example/.../UnqualifiedDataTypes.xsd 32 kB
-
Hide
- castor_example.zip
- 23/Jan/07 3:46 PM
- 18 kB
- Daniel Nilsson
-
- castor_example/sample.xml 5 kB
- castor_example/SyncItem.xsd 20 kB
- castor_example/SyncItem.xsd.binding 2 kB
- castor_example/.../CodeLists.xsd 4 kB
- castor_example/.../CodeLists.xsd.binding 0.5 kB
- castor_example/.../CodeList_CurrencyCode_ISO_7_04.xsd 0.9 kB
- castor_example/.../CodeList_CurrencyCode_ISO_7_04.xsd.binding 0.5 kB
- castor_example/.../CodeList_MIMEMediaTypeCode_IANA_7_04.xsd 0.9 kB
- castor_example/.../CodeList_MIMEMediaTypeCode_IANA_7_04.xsd.binding 0.5 kB
- castor_example/.../CodeList_LanguageCode_ISO_7_04.xsd 1 kB
- castor_example/.../CodeList_LanguageCode_ISO_7_04.xsd.binding 0.5 kB
- castor_example/.../QualifiedDataTypes.xsd 7 kB
- castor_example/.../QualifiedDataTypes.xsd.binding 0.5 kB
- castor_example/.../CodeList_UnitCode_UNECE_7_04.xsd 0.9 kB
- castor_example/.../CodeList_UnitCode_UNECE_7_04.xsd.binding 0.5 kB
- castor_example/.../UnqualifiedDataTypes.xsd 32 kB
- castor_example/.../UnqualifiedDataTypes.xsd.binding 0.5 kB
-
Hide
- example.zip
- 15/Jan/07 4:14 AM
- 38 kB
- Daniel Nilsson
-
- generated_source/org/oagis/.castor.cdr 0.2 kB
- generated_source/.../BusinessObjectDocumentType.java 9 kB
- generated_source/.../BusinessObjectDocumentTypeDescriptor.java 11 kB
- generated_source/org/.../types/.castor.cdr 0.4 kB
- generated_source/.../ActionCodeEnumerationType.java 6 kB
- generated_source/.../ActionCodeEnumerationTypeDescriptor.java 4 kB
- generated_source/.../ResponseCodeEnumerationType.java 4 kB
- generated_source/.../ResponseCodeEnumerationTypeDescriptor.java 4 kB
- generated_source/.../SystemEnvironmentCodeEnumerationType.java 4 kB
- generated_source/.../SystemEnvironmentCodeEnumerationTypeDescriptor.java 4 kB
- generated_source/org/oagis/Example.java 4 kB
- generated_source/.../ExampleDescriptor.java 4 kB
- generated_source/org/.../ExampleType.java 4 kB
- generated_source/.../ExampleTypeDescriptor.java 4 kB
- generated_source/org/.../.castor.cdr 0.3 kB
- generated_source/org/.../CodeType.java 18 kB
- generated_source/.../CodeTypeDescriptor.java 21 kB
- generated_source/org/.../IdentifierType.java 16 kB
- generated_source/.../IdentifierTypeDescriptor.java 18 kB
- generated_source/org/.../TextType.java 6 kB
- generated_source/.../TextTypeDescriptor.java 8 kB
- XSD/Example.xsd 3 kB
- XSD/Example.xsd.binding 1 kB
- XSD/.../CodeLists.xsd 4 kB
- XSD/.../CodeList_LanguageCode_ISO_7_04.xsd 1 kB
- XSD/.../QualifiedDataTypes.xsd 7 kB
- XSD/.../UnqualifiedDataTypes.xsd 32 kB
-
- patch.c1839.20071217.txt
- 17/Jan/07 5:51 AM
- 1.0 kB
- Werner Guttmann
-
- patch.c1839.tests.20070118.txt
- 18/Jan/07 2:32 AM
- 54 kB
- Werner Guttmann
Activity
Daniel, would you please be able to attach a sample XML document that you'd want to successfully unmarhal against the classes generated ?
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'.
Initial patch for review. As already mentioned, all CTF tests complete without any hiccups ....
.
Daniel, any objections against using the sample XML schemas to enhance our test suite ?
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.
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.
Initial patch for review. I'd still like to use a 'real' XML document rather than a knocked up .....
.
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:
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.
Daniel, with the last archive you attached, code generation completes with errors. Any idea why ?
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.
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