2011-03-24 86 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