XML Schema验证Android中 [英] XML Schema Validation in Android

查看:192
本文介绍了XML Schema验证Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个XML,我想用的架构即验证,
XSD文件,但也有由Android为没有提供直接的班
相同的,如果我没看错.........并且有一个名为外部JAR
jaxp1.3这犯规让我来编译code是不是因为
台式机和Android字节code有什么不同?其具有的类
模式工厂和验证其确实验证的东西......是
还有一个提供其他选择。任何帮助将是AP preciated .....
拼命寻找俺们..........

I have created an XML and i want to validate with schema i.e, xsd file but there are no direct classes provided by android for the same if i am not wrong ......... and there is an external jar named jaxp1.3 which doesnt allow me to compile the code is it because the bytecode of desktop and android are different? which has the classes schema factory and validator which does the validation stuff ......Is there an other option available . Any help would be appreciated ..... desperately searching for the ans..........

推荐答案

它的发布由谷歌的已知问题的这里

It's a known issue posted by Google here

解决方案是使用Apache Xerces的移植到Android。
有一个项目这里

The solution is to use Apache Xerces ported to Android. There is a project here

您必须做一个SVN chekout和proyect导出到一个jar文件作为你的Andr​​oid proyect库使用。

You have to do a svn chekout and export the proyect to a jar file to use as a library in your android proyect.

在code到实例SchemaFactory的变化不大。
我告诉你一个例​​子:

The code to instance SchemaFactory change a little. I show you an example:

import mf.javax.xml.validation.Schema;
import mf.javax.xml.validation.SchemaFactory;
import mf.javax.xml.validation.Validator;
import mf.org.apache.xerces.jaxp.validation.XMLSchemaFactory;

SchemaFactory  factory = new XMLSchemaFactory();
Schema esquema = factory.newSchema(".../file.xsd");

这篇关于XML Schema验证Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆