Page 1 of 1

XML Datasource: Relations do not work

Posted: Mon Jan 28, 2019 1:36 pm
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

Re: XML Datasource: Relations do not work

Posted: Tue Jan 29, 2019 11:20 pm
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.

Re: XML Datasource: Relations do not work

Posted: Wed Jan 30, 2019 12:12 pm
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>

Re: XML Datasource: Relations do not work

Posted: Wed Jan 30, 2019 2:38 pm
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.

Re: XML Datasource: Relations do not work

Posted: Mon Oct 11, 2021 9:22 am
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.

Re: XML Datasource: Relations do not work

Posted: Tue Oct 12, 2021 2:39 pm
by Lech Kulikowski
Hello,

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

Thank you.