Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Blocker
-
Resolution: Unresolved
-
Affects Version/s: 1.0.3
-
Fix Version/s: None
-
Component/s: XML
-
Labels:None
-
Number of attachments :2
Description
When a type extends another type but restricts the content, the generated classes will not compile since the return type of the base class is not the same as for the subclass.
Attached you will find a slice of UBL 1.0 that demonstrates the problem by running Ant. The compiler output is
...\se\exder\external\ubl\sdt\UBLAmountType.java:80: getAmountCurrencyID() in se.exder.external.ubl.sdt.UBLAmountType cannot override getAmountCurrencyID() in se.exder.external.ubl.udt.AmountType; attempting to use incompatible return type
found : se.exder.external.ubl.codelist.types.CurrencyCodeContentType
required: java.lang.String
public se.exder.external.ubl.codelist.types.CurrencyCodeContentType getAmountCurrencyID()
This was no problem in version 0.9.9.1 but prevents one from using Castor 1.x for UBL (or other complex/core component) schemas.
-
Hide
- MinimizedSubclassTest.zip
- 19/Sep/06 2:25 AM
- 8 kB
- Mattias Jiderhamn
-
- codelist/UBL-CodeList-CurrencyCode-1.0.xsd 4 kB
- common/UBL-CoreComponentTypes-1.0.xsd 3 kB
- common/UBL-SpecializedDatatypes-1.0.xsd 3 kB
- common/UBL-UnspecializedDatatypes-1.0.xsd 3 kB
- build.xml 2 kB
- SftiBasic-mapping-binding.xml 4 kB
-
Hide
- Full-UBL-example.zip
- 31/May/07 9:59 AM
- 77 kB
- Mattias Jiderhamn
-
- codelist/UBL-CodeList-AcknowledgementResponseCode-1.0.xsd 5 kB
- codelist/UBL-CodeList-AllowanceChargeReasonCode-1.0.xsd 26 kB
- codelist/UBL-CodeList-ChannelCode-1.0.xsd 14 kB
- codelist/UBL-CodeList-ChipCode-1.0.xsd 5 kB
- codelist/UBL-CodeList-CountryIdentificationCode-1.0.xsd 57 kB
- codelist/UBL-CodeList-CurrencyCode-1.0.xsd 42 kB
- codelist/UBL-CodeList-DocumentStatusCode-1.0.xsd 6 kB
- codelist/UBL-CodeList-LatitudeDirectionCode-1.0.xsd 5 kB
- codelist/UBL-CodeList-LineStatusCode-1.0.xsd 6 kB
- codelist/UBL-CodeList-LongitudeDirectionCode-1.0.xsd 5 kB
- codelist/UBL-CodeList-OperatorCode-1.0.xsd 5 kB
- codelist/UBL-CodeList-PaymentMeansCode-1.0.xsd 23 kB
- codelist/UBL-CodeList-SubstitutionStatusCode-1.0.xsd 5 kB
- common/SFTI-CommonAggregateComponents-1.0.xsd 18 kB
- common/UBL-CommonAggregateComponents-1.0.xsd 388 kB
- common/UBL-CommonBasicComponents-1.0.xsd 23 kB
- common/UBL-CoreComponentParameters-1.0.xsd 8 kB
- common/UBL-CoreComponentTypes-1.0.xsd 12 kB
- common/UBL-SpecializedDatatypes-1.0.xsd 4 kB
- common/UBL-UnspecializedDatatypes-1.0.xsd 18 kB
- maindoc/SFTI-BasicInvoice-1.0.xsd 4 kB
- 1000000000000.7301002000009.invoic.20061115.165601.13396.msh.xml 6 kB
Activity
Mattias, for the problem with the unmarshal() methods (incorrect return types being used), I have created a separate sub-task.
Mattias, are you in a position to provide me with a patch that you are internally using to make 1.0 work (as 0.9.9.1 did) ?
"Mattias, are you in a position to provide me with a patch that you are internally using to make 1.0 work (as 0.9.9.1 did)"
No. And I probably won't have time to give it a try within this week nor the next one. I'll get back if I make such a patch.
No problem. Back to the subject of this issue ...
I am just reading http://www.w3.org/TR/xmlschema-0/#DerivByRestrict, and it looks to me that actually changing the type of an attribute as a result of a restriction is not an option with XML schemas. Having said that, this is the XML schema primer, so I will try to hunt down the relevant spec fragments from the parts 1 and 2 of the XML schema spec.
Mattias, can you please attach a valid and well-formed sample XML document that unmarshals successfully against the schemas attached ?
Mattias, as I have got a new dependency on this issue, can you please help me out with my little request ?
There was no time to fix this before delivery, so we had to stick with 0.9.9.1.
But now, I am back at the point of looking into upgrading!
I will attach a full blown schema including valid XML.
It is based on a standard use by Swedish authorities. The Danish authorities use a similar schema based on an older UBL (core component) version. What I am trying to say is: This is not a limited special use case - this is standard procedure in more and more global projects.
AFAIK the type is not actually changed from a schema perspective, rather what is a string in a base class is restricted to an enumeration of strings in a sub class.
The problem, in this case, is that Castor generates Java classes for the enumeration types, as of CASTOR-1267.
I'm to unexperienced with Castor internal code to have a solution (other than undoing CASTOR-1267 ...) yet. The correct way of handling this might be setting the actual JClass of the _superClass, rather than just the name. Then in FieldInfo you can check if the type of the superclass attribute is different then the type of the current class attribute.
Although I assume the classes are not parsed in "top to bottom" order?
Mattias, there's actually a second problem that manifests itself through this set of XMl schemas, i.e. the fact that the unmarshal method is generated incorrectly as well.