Igor's Blog

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

, , ,
About — I'm an enthusiastic software engineer and consultant interested in many fields including J2EE, programming, electronics, 3D printing, video games, wood working and gardening.
See my Resume for more information.
The views expressed in this blog are my own and not those of my employer.
comments powered by Disqus
My other posts you may like...
Programming, DIY, Games, Hacks, Tech and more.
Follow me on...
Current and Past Projects
See my Resume

Subscribe


RSS Feed

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

Recent Blog Posts

Base64 Encode or Decode on the command line without installing extra tools on Linux, Windows or macOS

How to install Panel Glide Blinds from Blinds Online

Showing whitespace characters in vi

Using Jackson to automatically convert Java POJOs to JSON as output of a Jersey service

Enable quick access to the keyboard and emoji viewer in macOS

How to tell if your site is served via CloudFlare

Googe Cloud Platform doesn't support CloudFlare's free edge certificates

Fixing the invalid private key error in the Google Cloud Platform App Engine app Settings page

Cleaning the sticky PlayStation controller analogue thumb sticks

Invoking interactive shell scripts non-interactively

Recent Galleries

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

DIY indoor apartment grow light wiring

Good Friday Electronics fun Easter Bunny LED PCB Kit IBEABU-01.0

Top Categories

Blogs I follow

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth

Friends

RAWS Parts Online
Alpha Dimensions Hosting
Kristensen Photography
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity
Follow me on... 
     
...or subscribe for updates!

Don't show this again