将架构加载到数据集时出错"Invalid XPath selection inside field node. Cannot find .."



我想向一个数据集添加一个XML模式(Main.xsd),该数据集包含另一个模式(base.xsd),该模式定义了前一个模式中使用的复杂类型。

主。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 "类型。xsd.

现在,当我尝试包含Main。xsd放入数据集,则抛出一个错误:"字段节点内的XPath选择无效。

如果我对该元素使用一些基本类型,如"xs:int",则加载到数据集的工作很好。有人能帮我解决这个问题吗??

当我将唯一块修改为:

时,问题得到了解决
<xs:unique name="ReportConst" msdata:PrimaryKey="true"> 
<xs:selector xpath="." /> 
<xs:field xpath="EmployeeID" /> 
</xs:unique>

需要指定UE_SignedInt元素的命名空间

    <xs:element name="EmployeeID" type="xxx:UE_SignedInt"/>

最新更新