title: How can I specify which XML parser implementation to use?
body: <p>I am currently trying to write an app (a game) that will, I hope, run on both desktop and Android.  The data format I have chosen to use is XML because it's more flexible and powerful than JSON, it performs better than a database and I am familiar with it and like it.</p>
  
  <p>However, I'm beginning to wonder if it's going to actually be possible to use XML.</p>
  
  <p>In addition to plain old XML I'm also using XInclude in my data structures and XPath to locate the relevant nodes.  This seems to require that I also validate my XML during parse, which is fine because I had already written the XML Schema when developing the XML in the first place.</p>
  
  <p>I've managed to get everything working on the desktop, however, as soon as I tried to run it on Android it failed. It seems that the XML parser used by default on Android doesn't support XInclude (<a href="https://github.com/jOOQ/jOOX/issues/149" rel="nofollow noreferrer">source</a>).</p>
  
  <p>I've added the following line to my build.gradle:</p>
  
  <pre><code>compile "xerces:xercesImpl:2.12.0"
  </code></pre>
  
  <p>and it seems to have worked in that the SchemaFactory seems to be resolving to the Xerces one as evidenced by the debugging output:</p>
  
  <pre><code>08-21 14:19:35.488 8254-8332 W/System.err: JAXP: Reading jar:file:/data/app/uk.co.redfruit.gdx.wobbegong-geDT8AfzN-vHBlDA-lE0_g==/base.apk!/META-INF/services/javax.xml.validation.SchemaFactory
      JAXP: instantiating org.apache.xerces.jaxp.validation.XMLSchemaFactory
  </code></pre>
  
  <p>But the DocumentBuilderFactory appears to be using the default Android one because it still throws the error:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: This parser does not support specification "Unknown" version "0.0"
  </code></pre>
  
  <p>Which is what is always thrown when you call setXIncludeAware on the DocumentBuilderFactory (See above link).</p>
  
  <p>I had assumed that including it in my gradle build file would do the trick and it seems like it partly has, but not enough.</p>
  
  <p>I'm hoping that all crosss platform XML parsing problems will be solved by using the same parser implementation on all platforms, but it doesn't seem as straight forward as that...</p>