Page 1 of 1

Relationships between data tables not working Java

Posted: Mon Mar 01, 2021 8:48 pm
by LuisRamirez-
Hi, i'm having issues when trying to relate data tables from an XML(Parent to child scheme on nodes) on my project, but when i use the Stimulsoft designer i get my data related as intended on .mrt.

The data on the red rectangle is the one coming from another node for example, let's say, "Car". Every "Car" has a "Brand" and a "Brand" has different kind of "Models". That's just an example of what are we trying to do, but simplified. Here's the XML relationship we actually have:

Code: Select all

<Concepto Cantidad="1" ClaveProdServ="36" ClaveUnidad="45" Descripcion="CAR" Importe="22.85" NoIdentificacion="BZC316" Unidad="Pieza" ValorUnitario="22.85">
	<Impuestos>
		<Traslados>
			<Traslado Base="22.85" Importe="1.83" Impuesto="002" TasaOCuota="0.080000" TipoFactor="Tasa"/>
		</Traslados>
	</Impuestos>
</Concepto>
And as you can see, the Stimulsoft designer 2021.1.1 can render this relationship correctly
Designer 1.png
Designer 1.png (25.29 KiB) Viewed 4977 times
But this is different when i try to render it on my program:
Designer 2.png
Designer 2.png (92.84 KiB) Viewed 4977 times
Is like if the relationship created to associate these 2 nodes is not being rendered or loaded. Here's how we generate the .PDF from the .MRT with the .XML file:

Code: Select all

StiXmlDatabase xmlDatabase = new StiXmlDatabase("xml", pathToXml);
StiReport renderReport;

renderReport = StiSerializeManager.deserializeReport(new File(pathToMrt));
renderReport.getDictionary().getDatabases().clear();
renderReport.getDictionary().getDatabases().add(xmlDatabase);
renderReport.setCalculationMode(StiCalculationMode.Interpretation);
renderReport.Render(false);

FileOutputStream outputStream = new FileOutputStream(pdfPath);
StiExportManager.exportPdf(renderReport, outputStream);
I think something like this is necessary for my project: viewtopic.php?f=8&t=59132&p=159065&hili ... ns#p159065
But i can't find anything on the documentation about this for Java, so i need to know how to solve this as this is the only thing peventing me from creating a new feature on a product. Thank's in advance.

Re: Relationships between data tables not working Java

Posted: Sat Mar 06, 2021 12:35 pm
by Lech Kulikowski
Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.

Re: Relationships between data tables not working Java

Posted: Mon Mar 08, 2021 5:24 pm
by LuisRamirez-
Lech Kulikowski wrote: Sat Mar 06, 2021 12:35 pm Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
We found the cause of the issue, it was because we used an non-indented .XML as a database, so we had to take the file we had stored on our DB and then indent it. Here's the code we use in case someone find it useful for Java:

Code: Select all

public String indentXml(String xml) {
        
        InputStream inputStream = null;
        String indentedXml = null;
        
        try{
            inputStream = new ByteArrayInputStream(xml.getBytes());
        
            DocumentBuilderFactory docbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = docbFactory.newDocumentBuilder();
            Document sourceDoc = dBuilder.parse(inputStream);

            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

            StreamResult result = new StreamResult(new StringWriter());
            DOMSource source = new DOMSource(sourceDoc);
            transformer.transform(source, result);
            indentedXml = result.getWriter().toString();
        }catch(Exception e){
            e.printStackTrace();
            indentedXml = xml;
        }finally{
            try{
                if(inputStream != null) inputStream.close();
            }catch(IOException ex){
            	e.printStackTrace();
            }
        }
        
        return indentedXml;
    }

Re: Relationships between data tables not working Java

Posted: Tue Mar 09, 2021 2:47 pm
by Lech Kulikowski
Hello,

Thank you for the provided information.

Re: Relationships between data tables not working Java

Posted: Tue Mar 09, 2021 3:29 pm
by LuisRamirez-
Lech Kulikowski wrote: Tue Mar 09, 2021 2:47 pm Hello,

Thank you for the provided information.
As a comment, it would be great if Stimulsoft included between their libraries an standardized method to do this, as it seems to be a requirement for Stimulsoft to load some features properly and, if possible, include this in some part of the product documentation to prevent future problems like this.

Re: Relationships between data tables not working Java

Posted: Wed Mar 10, 2021 10:58 pm
by Lech Kulikowski
Hello,

Thank you for your suggestion. We will investigate that.