Igor's Blog
Programming, DIY, Games, Hacks, and Tech

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...

Recent Blog Posts

How to enable the full stack trace in Maven's Surefire plugin for JUnit testing

Twelve elements of the Burst Mining Pool interface explained

TPG FTTB settings for the Billion BiPAC 8700AXL 1600 modem router

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

How to fix SoapUI javax.net.ssl.SSLHandshakeException calling WebLogic 12.2 web services on Java 8

Woolworths (WOW) shares disappeared from Computer Share Investor Centre

Connecting the Dell UltraSharp U3415W monitor to a MacBookPro via USB-C

How to add/change PHP versions appearing in MAMP preferences

Fix the ORA-00904: ORA_ROWSCN: invalid identifier error in SQLDeveloper with a few easy steps

G Suite Gmail is broken on Safari due to new Google Content Security Policy settings

Recent Galleries

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

DIY spare parts computer build with a RAIDMAX Anura case

Fake 'Lepin' brand Lego packaging

Hardwood garden bench with clear resin void filler

Fixing a 3D printer extruder that stopped heating up

Easily increase disk space in a Lenovo Ideapad 100S 14" laptop with an M.2 SSD

Making a multi-piece 3D printed solder spool holder stand

My Other Web Sites

Igor and Elise's Travels
Riverside Expressway Cam
300 George St Blogumentary

My Online Tools

UUID to OID Converter
Guru JSON-RPC Tester
Extrudifier Object Designer
Travel ┬ÁBlog

Blogs and Friends

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

Blog Activity

Blog Activity
Don't forget to
my Facebook page for more great articles!
Don't show this again