Example file: XSD file
<?xml version="1.0" standalone="yes"?>
<xschema id="STG_Additional_Labs" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn
chemas-microsoft-com:xml-msdata">
<xs:element name="STG_Additional_Labs" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xsequence>
<xs:element name="FacilityID" type="xs:int" minOccurs="0" />
<xs:element name="Comment" type="xstring" minOccurs="0" />
<xs:element name="Deleted" type="xs:boolean" minOccurs="0" />
<xs:element name="Lab_Date" type="xsateTime" sql
atatype="dateTime" minOccurs="0" />
<xs:element name="Lab_Name" type="xstring" minOccurs="0" />
<xs:element name="Lab_Time" type="xstring" minOccurs="0" />
<xs:element name="Lab_Value" type="xstring" minOccurs="0" />
<xs:element name="PIID" type="xs:int" minOccurs="0" />
<xs:element name="rowguid" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
<xs:element name="RowIDGuid" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
<xs:element name="SaveDateTime" type="xsateTime" sql
atatype="dateTime" minOccurs="0" />
<xs:element name="VersionGuid" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
<xs:element name="PatientID" msdataataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs
tring" minOccurs="0" />
</xsequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xschema>
Example file: XML file
<?xml version="1.0" standalone="yes"?>
<STG_Additional_Labs>
<Table>
<FacilityID>648</FacilityID>
<Deleted>false</Deleted>
<Lab_Date>2007-05-30T00:00:00-04:00</Lab_Date>
<Lab_Name>Stool Red Subst</Lab_Name>
<Lab_Value>trace</Lab_Value>
<PIID>14</PIID>
<rowguid>03cc9264-8829-464f-b01d-2b18ee4ccdfb</rowguid>
<RowIDGuid>ff9e4e59-6716-46d4-bfcb-61777ed8cf5d</RowIDGuid>
<SaveDateTime>2007-05-30T10:18:24.52-04:00</SaveDateTime>
<VersionGuid>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</VersionGuid>
<PatientID>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</PatientID>
</Table>
<Table>
<FacilityID>648</FacilityID>
<Deleted>false</Deleted>
<Lab_Date>2007-05-19T00:00:00-04:00</Lab_Date>
<Lab_Name>Stool Red Sub</Lab_Name>
<Lab_Value><0.25/ neg</Lab_Value>
<PIID>14</PIID>
<rowguid>876ca5f9-5c0f-4a74-bf03-2e86260ca2a1</rowguid>
<RowIDGuid>45c45895-8008-40ed-a779-c478d476c15b</RowIDGuid>
<SaveDateTime>2007-05-19T10:13:53.857-04:00</SaveDateTime>
<VersionGuid>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</VersionGuid>
<PatientID>b4b29c65-71e2-425a-9eb9-037acc7ae4d0</PatientID>
</Table>
</STG_Additional_Labs>Ack! Sorry about the emoticons!|||Actually, further work on this problem seemed to reveal that the Cast error was actually due to the connection string in my application being wrong (although it is used for all the other connections in the application). The error now coming back is this:
<?xml version="1.0"?><Result State="FAILED"><Error><HResult>0x80004005</HResult><Description>
<![CDATA[Reference to undeclared namespace prefix: 'sql'.
]]></Description><Source>Schema mapping</Source><Type>FATAL</Type></Error></Result>
What would be the proper way to specify the SQL namespace in the top of the file?|||I have essentially resolved my problem by not trying to output the XML data to then read it in later. I am now using the SQLBulkLoad classes to pump the data from a DataTable to the destination SQL server. It would be nice however to have a method in the SQLReader/Writer that can write out a SQL friendly XSD file, so that it can be used later by the SQLXMLBulkLoad class.
No comments:
Post a Comment