I have the following XSD created in VS.NET 2003:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="ReferralSch ama" targetNamespace ="http://test.org/Referral"
elementFormDefa ult="unqualifie d"
xmlns="http://test.org/Referral" xmlns:mstns="ht tp://test.org/Referral"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:complexTy pe name="ReferralT ype">
<xs:sequence>
<xs:element name="nReferral Id" msdata:ReadOnly ="true"
msdata:AutoIncr ement="true" type="xs:int"/>
<xs:element name="nPersonId " type="xs:int"/>
<xs:element name="nReferral Number" type="xs:int"/>
<xs:element name="dReferral Date" type="xs:dateTi me"/>
<xs:element name="dDateOfBi rth" type="xs:dateTi me"/>
<xs:element name="dDateOfDe ath" type="xs:dateTi me"/>
</xs:sequence>
</xs:complexType>
<xs:element name="Document" >
<xs:complexType >
<xs:choice maxOccurs="unbo unded">
<xs:element name="tReferral " type="mstns:Ref erralType"/>
</xs:choice>
</xs:complexType>
<xs:unique name="ReferralK ey" msdata:PrimaryK ey="true">
<xs:selector xpath=".//mstns:tReferral "/>
<xs:field xpath="mstns:nR eferralId"/>
</xs:unique>
</xs:element>
</xs:schema>
and am attempting to load it via the SqlXmlAdapter in SQLXML3.0 as follows:
try
{
SqlXmlCommand cmd = new SqlXmlCommand(C onnString);
cmd.RootTag = "ROOT";
cmd.CommandText = txtXPath.Text;
cmd.CommandType = SqlXmlCommandTy pe.XPath;
cmd.SchemaPath = "..\\..\\Referr alSchama.xsd";
//load data set
DataSet ds = new DataSet();
SqlXmlAdapter ad = new SqlXmlAdapter(c md);
ad.Fill(ds);
}
catch (Exception ex)
{
Console.Write(e x.Message);
}
I've attempting to use various XPath statements such as the following to
load the data, but it fails with the following exception every time:
"XPath: unable to find /XXXXX in the schema".
XPath tried:
tReferral
tDocument/tReferral
Document/tReferral/nReferralId=1
tReferral/nReferralId=1
Document/tReferral/[@nReferralId=1]
tReferral/[@nReferralId=1]
Anyone know what I'm doing wrong?