Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FHIR JAXB XJC Code generation

I am trying to generate java code from an xsd for FHIR.

I downloaded the code generation schema from here and then I ran:

xjc patient.xsd

But I've got the following exception:

parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'Account' to a(n) 'type definition' component.
  line 332 of file:/Users/gerard/Downloads/fhir-codegen-xsd/fhir-base.xsd

[ERROR] src-resolve: Cannot resolve the name 'DetectedIssue' to a(n) 'type definition' component.
  line 354 of file:/Users/gerard/Downloads/fhir-codegen-xsd/fhir-base.xsd

[ERROR] src-resolve: Cannot resolve the name 'ImplementationGuide' to a(n) 'type definition' component.
  line 380 of file:/Users/gerard/Downloads/fhir-codegen-xsd/fhir-base.xsd

[ERROR] src-resolve: Cannot resolve the name 'MedicationOrder' to a(n) 'type definition' component.
  line 387 of file:/Users/gerard/Downloads/fhir-codegen-xsd/fhir-base.xsd

[ERROR] src-resolve: Cannot resolve the name 'QuestionnaireResponse' to a(n) 'type definition' component.
  line 409 of file:/Users/gerard/Downloads/fhir-codegen-xsd/fhir-base.xsd

[ERROR] src-resolve: Cannot resolve the name 'Parameters' to a(n) 'type definition' component.
  line 425 of file:/Users/gerard/Downloads/fhir-codegen-xsd/fhir-base.xsd

[ERROR] src-resolve: Cannot resolve the name 'MeasuredQuantity' to a(n) 'type definition' component.
  line 225 of file:/Users/gerard/Downloads/fhir-codegen-xsd/questionnaireanswers.xsd

I've imported to eclipse all the xsd and I see the same errors in fhir-base.xsd. Not sure how to solve it because for example the account.xsd is in the same directory.

like image 876
Gerard Ribas Avatar asked Nov 26 '25 22:11

Gerard Ribas


1 Answers

I was having the same problem. I've tried three resources from the archive provided on the fhir website:

fhir-base.xsd
fhir-all.xsd
fhir-single.xsd

Every error seems to take the same form (73 of these entries) against fhir-base.xsd...

[ERROR] Property "Lang" is already defined. Use <jaxb:property> to resolve this conflict.
  line 323 of file:/E:/fhir-spec/resources/fhir-all-xsd/fhir-xhtml.xsd

[ERROR] The following location is relevant to the above error
  line 324 of file:/E:/fhir-spec/resources/fhir-all-xsd/fhir-xhtml.xsd

Just trying some brute-force tactics.. I found and commented out a few lines in fhir-xhtml.xsd:

Lines 323, 324
<xs:attribute name="lang" type="LanguageCode"/>
<xs:attribute ref="xml:lang"/>

Line 1351
<xs:attribute name="lang" type="LanguageCode"/>

After this I was able to generate code successfully.

mkdir gen
xjc -d gen fhir-base.xsd

I couldn't find anywhere "official" eg github, etc to file an issue. I'm not exactly sure of the intent of the xhtml stuff to begin with, but I wonder if what may be happening here is a conflict between the fhir data type 'LanguageCode' and the html specification for language code?

Good luck!

like image 179
Rob Resendez Avatar answered Nov 28 '25 14:11

Rob Resendez



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!