2

I am trying to validate the XML using a local schema file (xsd) in an application that will be run on android. I followed the instructions on the android developer docs here.

I am able to validate my xml file in java but it raises an IllegalArgument exception (code mentioned below) when run on android.

SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

Please advice on how to proceed with XML schema validation on android. Are there any schema validation libraries that work on android ? Thanks in advance.

user591410
  • 3,051
  • 5
  • 21
  • 30

1 Answers1

2

The API is here in Android, but not the implementation (more). So the only way is to add the functionality by some external jar, Crimson or Xerces. Not a great problem. Have you looked here?

Community
  • 1
  • 1
Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • Thanks for the answer but I looked at the javax.xml.validation.SchemaFactory.class file and I see that there is no implementation. The API is there but the implementation is missing. Is XML schema validation possible in android? – user591410 Jun 06 '12 at 18:17
  • You are aboslutely correct. So the only way is to add the functionality by some external jar. Not a great problem. – Gangnus Jun 08 '12 at 06:48
  • Thanks for the comment. I tried Xerces but having problems performing schema validation with it too (similar problems as here[link](https://github.com/hunterhacker/jdom/wiki/JDOM2---Android-with-Xerces)). Have you tried validating with Xerces? I am yet to try Crimson. – user591410 Jun 08 '12 at 14:43