Android XML validation using XSD ( both xerces and SchemaFactory) error

此生再无相见时 提交于 2019-12-12 06:13:32

问题


Now, I'm having some pb with XML validation using XSD.

Since I use SchemaFactory:

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

It give me:

Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lorg/apache/xerces/impl/xs/SchemaGrammar;
Exception Ljava/lang/ExceptionInInitializerError; thrown while initializing Lorg/apache/xerces/impl/xs/XSConstraints;
java.lang.IllegalArgumentException: http://www.w3.org/2001/XMLSchema

Then I tried to switch to apache xerces and got this error (since importing xerces):

Error:Execution failed for task ':app:preDexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 1

I found these topics but they didn't help me:

Validator (xsd) for xml in android

xml schema conversion issue against xsd giving Illeagal exception in android applications

SchemaFactory doesn't support W3C XML Schema in platform level 8?

why java.exe exit with value 1 in android studio

I'm using Android Studio 1.2.2 and an Android 4.4.2. Any suggestion for me? Thanks,


回答1:


Short answer: xerces for android: https://code.google.com/p/xerces-for-android/source/checkout



来源:https://stackoverflow.com/questions/31075984/android-xml-validation-using-xsd-both-xerces-and-schemafactory-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!