2012-04-02 54 views
0

我爲我的xml文件寫了xml架構。我正在使用xmllint linux工具來驗證它。 我使用的命令:「xmllint --schema schema.xsd file.xml」我在xsd教程中讀到,我可以將xml文件引用到它的模式中。這對我有什麼幫助?我怎樣才能使用這個參考? 謝謝將xml架構引用到xml文件。解釋

回答

1

您可以使用noNamespaceSchemaLocation或SchemaLocation屬性從XML文件中引用架構。這告訴解析器在哪裏找到可用於驗證XML文件的模式。

<?xml version="1.0" encoding="utf-8"?> 
<!-- Created with Liquid XML Studio 2012 Developer Edition 10.0.1.3941 (http://www.liquid-technologies.com) --> 
<Orders xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="MySchema.xsd"> 
    <order> 
    </order> 
</Orders>