Closed nvioli closed 5 years ago
- The elements
currency
andcurrencyType
are present in both the activities and organisations schema, which causes an error. I suggest they be moved to theiati-common
file.
This part of the fix seems fine to me, though if you run xjc
for each schema separately, you won’t run into this. I.e.:
$ xjc iati-activities-schema.xsd
$ xjc iati-organisations-schema.xsd
UPDATE: Actually, my approach looks like it will mess up ObjectFactory
, so you’re right – it’s probably preferable to move stuff to iati-common.
- There is a conflict in the
documentLinkWithReceipientCountry
element which manifests as the following error:
Oh, interesting. This doesn’t happen on the version-2.02
branch, so this issue was introduced at version-2.03
(when a lot of stuff was refactored into complexType
s, including documentLinkWithReceipientCountry
[sic]). I can’t exactly tell what the problem is either, but I think you’re right – I think L796 of iati-organisations-schema.xsd may be a duplicate of L251 of iati-common.xsd, so it can probably be safely removed.
https://github.com/IATI/IATI-Schemas/blob/a96c582f2f6873aa46b42df2d24d69f3128b24e4/iati-organisations-schema.xsd#L796
https://github.com/IATI/IATI-Schemas/blob/a96c582f2f6873aa46b42df2d24d69f3128b24e4/iati-common.xsd#L251
if you run
xjc
for each schema separately, you won’t run into this
That's true, not sure why I thought that wouldn't work. Still probably best to DRY it up.
I think L796 of iati-organisations-schema.xsd may be a duplicate of L251 of iati-common.xsd, so it can probably be safely removed.
Yes, that was my thought too.
Let me know if I can do anything else to help!
Still probably best to DRY it up.
Agreed!
if you run
xjc
for each schema separately, you won’t run into this
I just tried again and realized this won't work because each of the xjc
commands creates an ObjectFactory
which is responsible for creating the rest of the objects. The ObjectFactory
created by the second command will only contain methods to create the objects in the second schema, so I wouldn't be able to create any objects from the first schema.
Possible workarounds would be to change the classname of the generated factory (OrganisationObjectFactory
and ActivitiesObjectFactory
), or manually merge the two generated classes, but it's much easier just to pass both schemas to xjc
so all classes and methods are created at once.
Yeah, I spotted that too:
UPDATE: Actually, my approach looks like it will mess up
ObjectFactory
, so you’re right – it’s probably preferable to move stuff to iati-common.
My organization's method of generating IATI data files is to process the schemas with xjc, then use the generated java classes to build the organization and activity objects, and marshal that object back into an xml file that complies with the schema.
Unfortunately in the process of upgrading our files from 1.x to 2.03, I notice that xjc throws errors when using the latest versions of the schema files. The command I'm using is:
There appear to be two problems:
currency
andcurrencyType
are present in both the activities and organisations schema, which causes an error. I suggest they be moved to theiati-common
file.documentLinkWithReceipientCountry
element which manifests as the following error:I don't fully understand the source of that error, so would appreciate a second set of eyes, however removing the following element on line 796 fixes the error:
I will open a PR shortly with the changes I made which allow me to run xjc successfully and to create valid files.