2011-03-24 68 views
0

如何將XML模式從* .xsd文件導入XML文件?你應該使用什麼指示? 當我寫的東西,如:如何將模式導入XML文件

<xs:schema xmlns:xs="http://schemas.microsoft.com/wix/2006/wi"> 
     <xs:include schemaLocation="wix.xsd"/> 
</xs:schema> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"></Wix> 

然後我得到「文檔不能包含多個根元素

+0

你究竟想要做什麼?在XML文件中引用XSD? – justkt 2011-03-24 14:10:53

+0

是的,我想引用XML文件中的XSD – 2011-03-24 14:33:14

回答

1
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xsi:schemaLocation="http://schemas.microsoft.com/wix/2006/wi wix.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> 
2

使用importinclude

+0

當我編寫如下所示的內容: \t \t < xs:include schemaLocation =「wix.xsd」/> 然後我得到「該文檔不能包含多個根 – 2011-03-24 14:32:02

+0

@ Bogdan0x400 - 您需要將XML名稱空間'xs'設置爲'http:// www.w3.org/2001/XMLSchema'。您的'targetNamespace'應該是'http://schemas.microsoft.com/ wix/2006/wi%22%3E'(或者,也許不是targetNamespace將該名稱空間設置爲名稱空間,例如'wi'並在該名稱空間中使用'wi'作爲您的元素)。 – justkt 2011-03-24 14:36:07

相關問題