I need to parse an XML file to DOM. I also want to validate this against an XSD schema, and be able to use a transformer to convert this with an XSL style sheet. While this worked fine as a plain Java application, I have had serious problems trying to get this to work on Android.
- First, I had to discover that the Android DOM parser is hard-coded to refuse validation. This is why I decided to try using Xerces instead of the native Android XML support.
- To get Xerces to run on Android, I understand a repackaged version of it is needed to avoid conflicts with the java core libary. So I followed the suggestion repeated by several contributors to use the Xerces-for-Android library on Google Code. Note: Since Google Code is closed, it now has been ported to the (currently same) Xerces-for-Android library on Github.
As pointed out there, this library can cause
NoClassDefFoundError
with various classes. In my application, I ran into this problem withDocumentBuilderFactory.newInstance()
(which needsDocumentBuilderFactoryImpl
).TransformerFactory.newInstance()
(which needsTransformerFactoryImpl
).
Is there any advice how to make Xerces-for-Android work with these?