Hello,
I am retrieving an XML document stored as a string from an Oracle stored procedure (XML was generated through a PL/SQL query):
I am trying to convert this document into a strongly typed class, based on an XSD. The XSD is defined as:
I used xsd.exe to generate a VB.NET partial class for this schema (the class was automatically named RowSet). I am attempting to use the following code to convert the string into my strongly typed XML-based class, but for some reason, it appears that the conversion is null.
ADO.NET seems to think that there are no ROW nodes in my document, even though there is definitely a node in the document. Instead, ROW is Null. Any ideas as to what I might be doing wrong? Thanks for your help.
Nick Ruiz
I am retrieving an XML document stored as a string from an Oracle stored procedure (XML was generated through a PL/SQL query):
Code:
<ROWSET>
<ROW>
<KY_PND_SEQ_TRANS>100000</KY_PND_SEQ_TRANS>
<KY_BA_LEAD_ZEROS>000000009</KY_BA_LEAD_ZEROS>
<DT_PERIOD_START>28-Jun-2007</DT_PERIOD_START>
<DT_PERIOD_END>30-Jul-2007</DT_PERIOD_END>
<KY_SUPPLIER>SUPPLIER'S NAME</KY_SUPPLIER>
<TX_CUST_NAME>CUSTOMER NAME</TX_CUST_NAME>
</ROW>
</ROWSET>
I am trying to convert this document into a strongly typed class, based on an XSD. The XSD is defined as:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="InvoiceSummary" targetNamespace="[URL unfurl="true"]http://tempuri.org/InvoiceSummary.xsd"[/URL] xmlns="[URL unfurl="true"]http://tempuri.org/InvoiceSummary.xsd"[/URL] xmlns:mstns="[URL unfurl="true"]http://tempuri.org/InvoiceSummary.xsd"[/URL] xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
<xs:element name="ROWSET">
<xs:complexType>
<xs:sequence>
<xs:element name="ROW" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="KY_PND_SEQ_TRANS" type="xs:integer" minOccurs="1" maxOccurs="1" />
<xs:element name="KY_BA_LEAD_ZEROS" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="DT_PERIOD_START" type="xs:date" minOccurs="1" maxOccurs="1" />
<xs:element name="DT_PERIOD_END" type="xs:date" minOccurs="1" maxOccurs="1" />
<xs:element name="KY_SUPPLIER" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="TX_CUST_NAME" type="xs:string" minOccurs="1" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I used xsd.exe to generate a VB.NET partial class for this schema (the class was automatically named RowSet). I am attempting to use the following code to convert the string into my strongly typed XML-based class, but for some reason, it appears that the conversion is null.
Code:
Dim clob As OracleLob = cmd.Parameters.Item("p_xml_clob").Value
Const XmlDEC As String = "<?xml version=""1.0"" encoding=""utf-8""?>"
Dim myXml As String = XmlDEC & ControlChars.CrLf & clob.Value
myXml = myXml.Replace("<ROWSET>", "<ROWSET xmlns:xsd=""[URL unfurl="true"]http://www.w3.org/2001/XMLSchema""[/URL] xmlns:xsi=""[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance""[/URL] xmlns=""[URL unfurl="true"]http://tempuri.org/InvoiceSummary.xsd"">")[/URL]
Dim myInvoiceSummary As New Mailer.ROWSET()
Using myReader As New IO.StringReader(myXml)
'Console.WriteLine(myReader.ReadToEnd)
Dim mySer As New Xml.Serialization.XmlSerializer(GetType(ROWSET))
myInvoiceSummary = DirectCast(mySer.Deserialize(myReader), Mailer.ROWSET)
End Using
If myInvoiceSummary.ROW.Length = 0 Then
' TODO: Log that no invoice needed to be written.
Console.WriteLine("No approval requests have been created. Either no transactions require approval or they have already been processed by this application.")
Return
End If
ADO.NET seems to think that there are no ROW nodes in my document, even though there is definitely a node in the document. Instead, ROW is Null. Any ideas as to what I might be doing wrong? Thanks for your help.
Nick Ruiz