XML Datasource: Relations do not work

Stimulsoft Reports.NET discussion
Post Reply
joro
Posts: 63
Joined: Wed Jan 27, 2010 7:35 am

XML Datasource: Relations do not work

Post by joro »

Hello,

I've created a report using a XML File as Datasource (ADO.NET Xml). Every ChildNode has a Relation to its parent and I created Databands for every childnode.
Everything is rendered correctly when I preview the report in the designer. But by the time I change the datasource programmatically to another XML file the relations break and will not be used.
As soon as I change to another file and call Synchronize(), new relations are added. The report uses neither my old nor the new relations and basically display everything that is in the file without any structure.
This is the code I use.

Code: Select all

StiReport Report = new StiReport();
                Report.Load(@"Resources\XmlTestReport.mrt");
                XmlDocument doc = new XmlDocument();
                doc.Load(pathToXml);
                string datasetName = Report.Dictionary.Databases[0].Name;
                XmlReader reader = XmlReader.Create(new StringReader(doc.OuterXml));
                System.Data.DataSet dataSet = new System.Data.DataSet(datasetName);
                dataSet.ReadXml(reader);
                Report.Dictionary.Clear();
                dataSet.DataSetName = datasetName;
                Report.RegData(datasetName, datasetName, dataSet);
                Report.Dictionary.Synchronize();

                Report.Show();
I have tried with and without

Code: Select all

Report.Dictionary.Clear()
and I have tried it with and without

Code: Select all

Report.Dictionary.Synchronize();
.

Another problem is that the report does not render anymore when my XML file is missing some nodes that the report would expect. When I skip the call to

Code: Select all

Report.Dictionary.Clear();
then missing nodes are no problem anymore. But still relations do not work.
I am using Stimulsoft Reports.Net 2018.2.3.

I have attached a sample project.
ReportInput1.xml works correctly because relations do not matter in this use case.
ReportInput2.xml is not rendering because there missing xml nodes - if you comment out Dictionary.Clear() it will render.
ReportInput3.xml is not rendering correctly because relations are broken.

Can you please look into this and tell me how to handle this?

thank you
Attachments
XmlReportDemo.zip
(43.97 KiB) Downloaded 155 times
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: XML Datasource: Relations do not work

Post by Lech Kulikowski »

Hello,

We are using standard NET Framework methods for working with XML. There some problems in NET Framework with nested XML data.
Please try to use separate tables without nested objects and XSD schemas for correct behavior.

Thank you.
joro
Posts: 63
Joined: Wed Jan 27, 2010 7:35 am

Re: XML Datasource: Relations do not work

Post by joro »

Hello,

the xml is transformed to separate tables in the report. Have you checked the report?
I can try to add a XML schema but I think that the problem will not be solved with this.
I edited the report before and after I updated the datasource and the relations all look the same to me.

Relations before - created by me:

Code: Select all

<relChildNodeToFirstNode Ref="6" type="DataRelation" isKey="true">
        <Active>True</Active>
        <Alias>relChildNodeToFirstNode</Alias>
        <ChildColumns isList="true" count="1">
          <value>FirstNode_Id</value>
        </ChildColumns>
        <ChildSource isRef="3" />
        <Dictionary isRef="1" />
        <Name>relChildNodeToFirstNode</Name>
        <NameInSource>relChildNodeToFirstNode</NameInSource>
        <ParentColumns isList="true" count="1">
          <value>FirstNode_Id</value>
        </ParentColumns>
        <ParentSource isRef="5" />
      </relChildNodeToFirstNode>
Relations after I update the dictionary (RegData()):

Code: Select all

<relChildNodeToFirstNode Ref="6" type="DataRelation" isKey="true">
        <Active>True</Active>
        <Alias>relChildNodeToFirstNode</Alias>
        <ChildColumns isList="true" count="1">
          <value>FirstNode_Id</value>
        </ChildColumns>
        <ChildSource isRef="3" />
        <Dictionary isRef="1" />
        <Name>relChildNodeToFirstNode</Name>
        <NameInSource>relChildNodeToFirstNode</NameInSource>
        <ParentColumns isList="true" count="1">
          <value>FirstNode_Id</value>
        </ParentColumns>
        <ParentSource isRef="5" />
      </relChildNodeToFirstNode>
      <FirstNode Ref="8" type="DataRelation" isKey="true">
	<Alias>FirstNode</Alias>
	<ChildColumns isList="true" count="1">
		<value>FirstNode_Id</value>
	</ChildColumns>
	<ChildSource isRef="3" />
	<Dictionary isRef="1" />
	<Name>FirstNode</Name>
	<NameInSource>FirstNode_ChildNode</NameInSource>
	<ParentColumns isList="true" count="1">
		<value>FirstNode_Id</value>
	</ParentColumns>
	<ParentSource isRef="5" />
</FirstNode>
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: XML Datasource: Relations do not work

Post by Lech Kulikowski »

Hello,

> the xml is transformed to separate tables in the report. Have you checked the report?

Should be separated in the XML file.
Please check the sample in the attachment.

Thank you.
Attachments
Demo.xsd
(12.72 KiB) Downloaded 221 times
Demo.xml
(1.79 MiB) Downloaded 202 times
joro
Posts: 63
Joined: Wed Jan 27, 2010 7:35 am

Re: XML Datasource: Relations do not work

Post by joro »

Hello,

did you find a solution for this problem?
We have the same problem, everything works fine in the Designer, but as soon as we add the xml file at runtime, the relations won't work.
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: XML Datasource: Relations do not work

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.
Post Reply