問題描述
我已經創建了一個 XML
并且我有一個 XSD
文件,并且我必須使用此架構驗證 xml,我可以獲得任何示例嗎?我必須將 xsd 文件放在我的項目中,以便我可以使用該架構進行驗證.
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.
推薦答案
根據documentation javax.xml.validation 從 API 級別 8 開始支持.
According to the documentation javax.xml.validation is supported since API level 8.
(我會測試并盡快報告)
(I will test that and report asap)
好吧,問題沒那么簡單:
Ok, the problem is not that simple:
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
在第 8 級和第 9 級 API 上均失敗并出現 IllegalArgumentException,如 這里
failed on both level 8 and level 9 API with an IllegalArgumentException as described here
除了找到同樣的故障報告外,Google 對此無能為力.API 在這里,但不是實現(默認情況下).
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).
這篇關于Android 架構驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!