我想将 XML 架构 (Main.xsd) 添加到数据集,其中包含定义前一个架构中使用的复杂类型的另一个架构 (base.xsd)。
Main.xsd 有一个定义 xs:unique 的块,其中包含选择器和字段,以唯一地将特定元素定义为主键。
这是 Main.xsd:
<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/Main.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" targetNamespace="http://tempuri.org/Main.xsd" attributeFormDefault="unqualified" elementFormDefault="qualified" version="3.0.4 01-07-2011">
<xs:include schemaLocation="base.xsd"/>
<xs:complexType name="Employees">
<xs:sequence>
<xs:element name="EmployeeID" type="UE_SignedInt"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Report" type=" Employees" />
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref=" Report " />
</xs:choice>
</xs:complexType>
<xs:unique name="ReportConst" msdata:PrimaryKey="true">
<xs:selector xpath=".//Report" />
<xs:field xpath="EmployeeID" />
</xs:unique>
</xs:element>
</xs:schema>
类型“UE_SignedInt”在 main.xsd 中包含的 base.xsd 中定义。
现在,当我尝试将 Main.xsd 包含到数据集中时,它会抛出错误:“字段节点内的 XPath 选择无效。找不到 EmployeeID”,因为 EmployeeID 使用在 base.xsd 中定义的类型。
如果我对此元素使用一些基本类型(例如“xs:int”),则加载到数据集的效果很好。有人可以帮我解决这个问题吗?
I want to add an XML schema(Main.xsd) to a dataset which includes another schema(base.xsd) defining the complex types used in the former one.
The Main.xsd has a block defining xs:unique with selector and field to uniquely define a particular element as the primary key.
Here is the Main.xsd:
<xs:schema id="NewDataSet" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/Main.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" targetNamespace="http://tempuri.org/Main.xsd" attributeFormDefault="unqualified" elementFormDefault="qualified" version="3.0.4 01-07-2011">
<xs:include schemaLocation="base.xsd"/>
<xs:complexType name="Employees">
<xs:sequence>
<xs:element name="EmployeeID" type="UE_SignedInt"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Report" type=" Employees" />
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref=" Report " />
</xs:choice>
</xs:complexType>
<xs:unique name="ReportConst" msdata:PrimaryKey="true">
<xs:selector xpath=".//Report" />
<xs:field xpath="EmployeeID" />
</xs:unique>
</xs:element>
</xs:schema>
The type “UE_SignedInt” is defind in the base.xsd which is included in Main.xsd.
Now , when I try to include Main.xsd into a dataset, it throws an error: “Invalid XPath selection inside field node. Cannot find EmployeeID” as EmployeeID uses the type which is defined in the base.xsd.
If I use some basic type like “xs:int” to this element , the loading into the dataset works fine. Could anyone please help me to resolve this issue??
发布评论
评论(2)
当我将唯一块修改为:
The issue was solved when I modifed the unique block as:
您需要指定 UE_SignedInt 元素的命名空间。
You need to specify the namespace of the UE_SignedInt element.