Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've written previously about fixing HL7 CDA schema compilation with XJC, now that I've been looking at FHIR it seems that there are name collisions in that schema too. The actual problem arises out of the W3C XHTML 1.0 Schema and not the FHIR schema per se.

This is the kind of error that XJC throws whenever trying to compile the FHIR schema:
 XJC Error
Error while parsing schema(s).Location [ fhir-xhtml.xsd{48,2902}].
com.sun.istack.SAXParseException2; systemId: fhir-xhtml.xsd; lineNumber: 48; columnNumber: 2902; Property "Lang" is already defined. Use <jaxb:property> to resolve this conflict.


Ok so that says that "Lang" is already defined and looking at that part of the XSD reveals this...
 XSD
<xs:attributeGroup name="i18n">
<xs:attribute name="lang" type="LanguageCode"/>
<xs:attribute ref="xml:lang"/>
...


It's pretty obvious why XJC would complain. There's a name collisions between the xml:lang reference and the lang attribute, both would get mapped to a variable named 'lang' in the generated Java code.

To fix it, it's just a matter of telling XJC to rename the xml:lang reference to 'xmlLang' when generating Java code while leaving the lang attribute as is. The following bindings would be suitable, see my CDA article linked above for the full binding file definition:
 Bindings
<jaxb:bindings schemaLocation="http://hl7.org/fhir/2016May/fhir-xhtml.xsd">
<jaxb:bindings node="//xs:attributeGroup[@name='i18n']/xs:attribute[@ref='xml:lang']">
<jaxb:property name="xmlLang"/>
</jaxb:bindings>
<jaxb:bindings node="//xs:element[@name='bdo']/xs:complexType/xs:complexContent/xs:extension/xs:attribute[@ref='xml:lang']">
<jaxb:property name="xmlLang"/>
</jaxb:bindings>
</jaxb:bindings>


Here's an answer from StackOverlow that is similar in nature and covers it in more detail.



Then it's just a matter of telling XJC that you want to use a binding file and the FHIR schema should compile!

-i

Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...
Hi! You can search my blog here ⤵
Or browse the recent top tags...

Recent Blog Posts

How to stop macOS adding shadows to window screenshots

How to run Atari Lynx games on the SNES Classic Mini

Maven dependency scopes with relation to WAR file packaging and the WEB-INF/lib directory

Hacking the Sonoff B1 WiFi LED bulb to run custom firmware

What does an idle WebLogic server run on the hour to cause a CPU spike

How to open the Sonoff B1 wifi LED bulb to access its internal circuitry

Australian release SNES mini classic unboxing and a quick play through

Troubleshooting high CPU usage for JVM threads

How to fix WebLogic high CPU usage due to a corrupted file store

Mini review of the Sonoff B1 WiFi light bulb

Recent Galleries

Atari Lynx repair - Part 5 - McWill LED screen mod installation

Atari Lynx repair - Part 4 - screen cover replacement

Atari Lynx repair - Part 2 - re-capping the motherboard

Atari Lynx repair - Part 3 - broken speaker replacement

Atari Lynx repair - Part 1 - introduction and case disassembly

Building a custom Atari Lynx game box storage shelf unit in a day

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity