Page 1 of 1

XML and NULL values for Numeric fields

Posted: Thu Aug 16, 2012 4:11 pm
by patwolf
How can NULL values be handled for numeric types through XML please? In the below example I get an error but when I enter 0 as the numeric value in the XML it works.
But as you know 0 != NULL :)

Thanks a lot,
Patrick

XSD

Code: Select all

<?xml version="1.0"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="shotgun">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="version">
<xs:complexType><xs:sequence>
<xs:element name="id" type="xs:integer" />
<xs:element name="frame_count" type="xs:integer" minOccurs="0" />
<xs:element name="sg_frames_aspect_ratio" type="xs:decimal" minOccurs="0" />
</xs:sequence></xs:complexType></xs:element>
</xs:choice></xs:complexType></xs:element>
</xs:schema>
XML

Code: Select all

<?xml version="1.0"?>
<shotgun>
  <version>
    <id>3743</id>
    <frame_count></frame_count>
    <sg_frames_aspect_ratio></sg_frames_aspect_ratio>
  </version>
</shotgun>
Error

Code: Select all

System.FormatException was caught
  Message=Input string was not in a correct format.
  Source=mscorlib
  StackTrace:
       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
       at System.Data.Common.Int64Storage.ConvertXmlToObject(String s)
       at System.Data.XmlDataLoader.LoadColumn(DataColumn column, Object[] foundColumns)
       at System.Data.XmlDataLoader.LoadTable(DataTable table, Boolean isNested)
       at System.Data.XmlDataLoader.LoadData(XmlReader reader)
       at System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving)
       at System.Data.DataSet.ReadXml(String fileName)
       at sg.reporting.webapp.Default.GetDs() in D:\Data\Documents\My Dropbox\Pixo_Pat\Code\user_patrickwolf\src\sg_reporting\src\sg.reporting\sg.reporting.webapp\Default.aspx.cs:line 140
       at sg.reporting.webapp.Default.PreviewReport(String fpn) in D:\Data\Documents\My Dropbox\Pixo_Pat\Code\user_patrickwolf\src\sg_reporting\src\sg.reporting\sg.reporting.webapp\Default.aspx.cs:line 160
  InnerException: 

Re: XML and NULL values for Numeric fields

Posted: Fri Aug 17, 2012 2:31 pm
by HighAley
Hello.

There is no Stimulsoft methods in the error stack. It's a .Net framework error.
Your type is not nullable so you get this error.

Thank you.

Re: XML and NULL values for Numeric fields

Posted: Mon Aug 20, 2012 4:32 am
by patwolf
If anybody else has the same problem.
http://msdn.microsoft.com/en-us/library/ybce7f69
<xsd:element name="key" type="xsd:string" nillable="true" />
<key xsi:nil="true"/>

Re: XML and NULL values for Numeric fields

Posted: Mon Aug 20, 2012 7:31 am
by HighAley
Hello.

In your first message the nillable attribute wasn't set to true. So did you solve your problem now?

Thank you.

Re: XML and NULL values for Numeric fields

Posted: Wed Aug 07, 2013 12:09 pm
by roomy
Hi,

I have the same issue. But here I just create a XML datasource and table inside mrt and pass xml to show data,
Where i put the nillable="true" in mrt file???

Please find the attachement.
I attach a xsd file for Issue, But actualy I dont have it directly in mrt.

Thanks

Re: XML and NULL values for Numeric fields

Posted: Thu Aug 08, 2013 1:14 pm
by HighAley
Hello.

Could you understand your issue more detailed?
What problem do you have?

Thank you.