FHIR Chat · xml entity error · hapi

Stream: hapi

Topic: xml entity error


view this post on Zulip Ben Spencer (Mar 04 2018 at 12:53):

I'm experiencing an error round-tripping the example json resources (parse, then encode to string, then parse again), that seems to be to do with xml entities in the narrative:

code: https://pastebin.com/raw/PWETu8v5
error: https://pastebin.com/raw/CRDN9JWD

There's a literal unicode © character in the original, which is converted to a &copy entity on the initial parse. That entity is then written out when encoding, and causes the error on the second parse.

The problem appears to have been introduced between 3.0.0 and 3.1.0.

view this post on Zulip Ben Spencer (Mar 04 2018 at 13:03):

Guessing this is relevant?

/**
 * Note that as of HAPI FHIR 3.1.0, this method no longer uses
 * the StAX XMLEvent type as the XML representation, and uses a
 * String instead. If you need to work with XML as StAX events, you
 * can use the {@link XmlUtil#parse(String)} and {@link XmlUtil#encode(List)}
 * methods to do so.
 */

view this post on Zulip James Agnew (Mar 04 2018 at 14:41):

Hi @Ben Spencer, StAX is still used for validation but possibly that is related. I notice in your stack trace that it's using Xerces. The first thing I would try it adding Woodstox to your classpath- Xerces is just awful as an XML provider. You should see a line similar to the following when HAPI first starts:

09:39:05.201 [main] INFO  ca.uhn.fhir.util.XmlUtil [DependencyLogImpl.java:75] - FHIR XML procesing will use StAX implementation 'Woodstox XML-processor' version '4.4.1'

view this post on Zulip Ben Spencer (Mar 04 2018 at 14:45):

hi @James Agnew , that seems to have fixed it, thanks


Last updated: Apr 12 2022 at 19:14 UTC