2015-10-15 26 views
1

我想驗證一些xml數據對在線模式。使用xmllint驗證xml針對遠程文件

$ xmllint --schema https://raw.githubusercontent.com/IATI/IATI-Schemas/version-2.01/iati-activities-schema.xsd --noout iati-data/*.xml 

返回:

warning: failed to load external entity "https://raw.githubusercontent.com/IATI/IATI-Schemas/version-2.01/iati-activities-schema.xsd" 
Schemas parser error : Failed to locate the main schema resource at 'https://raw.githubusercontent.com/IATI/IATI-Schemas/version-2.01/iati-activities-schema.xsd'. 
WXS schema https://raw.githubusercontent.com/IATI/IATI-Schemas/version-2.01/iati-activities-schema.xsd failed to compile 

然而,XSD確實存在:

curl https://raw.githubusercontent.com/IATI/IATI-Schemas/version-2.01/iati-activities-schema.xsd 

返回

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.01"> 

    <xsd:annotation> 
    <xsd:documentation xml:lang="en"> 
     International Aid Transparency Initiative: Activity-Information Schema 

     Release 2.01, 2014-10-21 

etc... 

不知道我做錯了...

回答

0

不幸的是,that XSD是使用支持XSD的相對路徑寫入的。甚至有一個音符在評論認爲效果:

NOTE: the xml.xsd and iati-common.xsd schemas must be in the 
    same directory as this one. 

如果你不能改變的XSD引用完整絕對URL到包括和導入的XSD,一個變通將下載主XSD及其依賴項,並改爲訪問本地主XSD。另一個解決方法是使用XML Catalog以絕對URL術語重新映射依賴XSD的位置。

+0

感謝這一點,下載主XSD以及兩個相關文件,然後運行本地工作的xmllint。 – user2761030