Java Code Generation from FHIR Schemas

I downloaded FHIR schemas fhir-codegen-xsd.zip from the page http://www.hl7.org/fhir/downloads.html, unzipped fhir-codegen-xsd.zip and executed JAXB binding compiler. But it failed to generate JAXB Java classes and threw the following errors:

parsing a schema…
[ERROR] undefined simple or complex type ‘Account’ line 332 of file:./fhir-codegen-xsd/fhir-base.xsd
[ERROR] undefined simple or complex type ‘DetectedIssue’ line 354 of file:./fhir-codegen-xsd/fhir-base.xsd
[ERROR] undefined simple or complex type ‘ImplementationGuide’ line 380 of file:./fhir-codegen-xsd/fhir-base.xsd
[ERROR] undefined simple or complex type ‘MedicationOrder’ line 387 of file:./fhir-codegen-xsd/fhir-base.xsd
[ERROR] undefined simple or complex type ‘QuestionnaireResponse’ line 409 of file:./fhir-codegen-xsd/fhir-base.xsd
[ERROR] undefined simple or complex type ‘Parameters’ line 425 of file:./fhir-codegen-xsd/fhir-base.xsd

[ERROR] undefined simple or complex type ‘MeasuredQuantity’ line 225 of file:./fhir-codegen-xsd/questionnaireanswers.xsd
Failed to parse a schema.

It seems that fhir-all.xsd is not complete and once
1) Removed the schema questionnaireanswers.xsd from fhir-all.xsd
2) Added the following schemas in fhir-all.xsd
It threw another error:

[ERROR] The following location is relevant to the above error line 324 of file:./fhir-codegen-xsd/fhir-xhtml.xsd
[ERROR] Property “Lang” is already defined. Use <jaxb:property> to resolve this conflict. line 323 of file:./fhir-codegen-xsd/fh ir-xhtml.xsd
[ERROR] The following location is relevant to the above error line 324 of file:./fhir-codegen-xsd/fhir-xhtml.xsd
[ERROR] Property “Lang” is already defined. Use <jaxb:property> to resolve this conflict. line 323 of file:./fhir-codegen-xsd/fhir-xhtml.xsd
[ERROR] The following location is relevant to the above error line 324 of file:./fhir-codegen-xsd/fhir-xhtml.xsd
[ERROR] Property “Lang” is already defined. Use <jaxb:property> to resolve this conflict. line 323 of file:./fhir-codegen-xsd/fhir-xhtml.xsd

I had to fix fhir-xhtml.xsd. Once this issue was fixed and re-executed JAXB binding compiler, I was able to generate the JAXB Java classes.

I wonder if anyone else ran into the same problem and if it is known issue of the published FHIR schemas or something that I am not aware of.

Thanks

  • Charles

HI Charles,
I am also facing the same issue,will you please explain me what you fixed in fhir-xhtml.xsd file to solve the issue ?

Thanks
Suraj