問(wèn)題描述
我已經(jīng)創(chuàng)建了一個(gè) XML
并且我有一個(gè) XSD
文件,并且我必須使用此架構(gòu)驗(yàn)證 xml,我可以獲得任何示例嗎?我必須將 xsd 文件放在我的項(xiàng)目中,以便我可以使用該架構(gòu)進(jìn)行驗(yàn)證.
I have created an XML
and i am having an XSD
file and i have to validate the xml with this schema ,can i get any example for doing that . And where i have to place the xsd file in my project so that i can validate with that schema.
推薦答案
根據(jù)documentation javax.xml.validation 從 API 級(jí)別 8 開(kāi)始支持.
According to the documentation javax.xml.validation is supported since API level 8.
(我會(huì)測(cè)試并盡快報(bào)告)
(I will test that and report asap)
好吧,問(wèn)題沒(méi)那么簡(jiǎn)單:
Ok, the problem is not that simple:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
在第 8 級(jí)和第 9 級(jí) API 上均失敗并出現(xiàn) IllegalArgumentException,如 這里
failed on both level 8 and level 9 API with an IllegalArgumentException as described here
除了找到同樣的故障報(bào)告外,Google 對(duì)此無(wú)能為力.API 在這里,但不是實(shí)現(xiàn)(默認(rèn)情況下).
Google doesn't help on that matter except to find the very same failure report. The API is here but not the implementation (as default).
這篇關(guān)于Android 架構(gòu)驗(yàn)證的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!