.. meta:: :description: Infrastructure Reports .. _reports: Reports ======= The task of report generation consists of producing a PDF document from a set of data. This data is generally obtained as a result of a task or workflow. The role of the plugin (workflow) is to generate: #. an XML data file, following a specific structure, and containing all the required data that may be used in a report; #. all the required image files that may be included in the report. The generation of a PDF document from a list of XML data files is done through this procedure: #. the content of the XML data files is merged into a single XML data tree; #. the merged XML data tree is transformed through an XSLT file to obtain a valid LaTeX document; #. the LaTeX document and all the image files specified by the XML data files are processed with a LaTeX compiler to produce a PDF document. The generation of a PDF document from a list of XML data files through a given XSLT UUID is done by calling the method :meth:`ORSServiceClass.xslt.xsltutil.XSLTUtil.generatePDFFromXML`. Structure of the XML data files ------------------------------- The XML data files that can be provided to be processed should follow this structure:: Dragonfly 2021.3 Object Research Systems (ORS), Inc. APluginClassName_aba92fe8276711ecb98af8ac6585ab6e General 1.0 (any other fields) (any other nodes) Such XML data files may be generated by subclassing :class:`ORSServiceClass.report.abstractreportgenerator.AbstractReportGenerator`. Node ^^^^^^^^^^^^^^^^ It acts as the root node of the XML data document. It contains a single ```` node, then any (but usually 1) number of ```` nodes. Node ^^^^^^^^^^^^^^^^^^ This node contains the details of the application that was used to generate the results. It contains the name, the version and the name of the company corresponding to the application. Node ^^^^^^^^^^^^^^^^^^^ This node contains a set of fields describing a given result. It contains at least of the nodes ````, ```` and ````. Any other fields may be added to contain the data of the result, for example the value of a measurement or the name of an image file:: Dragonfly 2021.3 Object Research Systems (ORS), Inc. TestReports_2a03860d260411ecaba4f8ac6585ab6e General 1.0 Fibers 50 0.2 20.00 0.060200000000000004 0.2801645295226413 True 0.055325000000000006 0.3509453642901375 True 0.045875 0.1849959000552852 False 0.07365000000000001 0.5893092092531802 True 0.08332500000000001 0.44606048263179615 True 0.10942500000000001 0.6245362263039491 True 0.129425 0.5796558703103682 True False
Fibers_50_2021_10_07_08_46_09_imageWorkingSliceWithSegmentation_1.png
iconAccepted_1.png
iconRejected_1.png
Node ^^^^^^^^^^^^^^^^^ This node contains the name of the plugin that generated the result data. The purposes are essentially: - for a human reader of the data file, to know what workflow this data has been generated from; - to identify the expected set of nodes; - to determine if a given XSL transform is applicable. Node ^^^^^^^^^^^^^^^^^ This node contains a name, for the purpose of supporting multiple kinds of reports from a single plugin. Node ^^^^^^^^^^^^^^^^^^^^ This node contains a version number, for the purpose of knowing if a given XSL transform is applicable. It should be incremented when the set of nodes is changed and previous versions of XSL transformation would not be applicable. Structure of the merged XML data -------------------------------- When generating a PDF document from a list of XML data files, the contents of the XML data files are merged into a single XML data tree to be transformed by the XSLT file. The merging is done by concatenating all ```` nodes from the XML data files into a single ```` node, as:: Dragonfly 2021.3 Object Research Systems (ORS), Inc. TestReports_2a03860d260411ecaba4f8ac6585ab6e General 1.0 Fibers 0 (...) Dragonfly 2021.3 Object Research Systems (ORS), Inc. TestReports_2a03860d260411ecaba4f8ac6585ab6e General 1.0 Fibers 50 (...) Dragonfly 2021.3 Object Research Systems (ORS), Inc. TestReports_2a03860d260411ecaba4f8ac6585ab6e General 1.0 Fibers 100 (...) .. note:: The method :meth:`ORSServiceClass.xslt.xsltutil.XSLTUtil.generateMergedXMLs` can be used to generate such a merged XML from a set of input files, for the purpose of developing a XSL transformation file. Structure of the XSL transformation files ----------------------------------------- The XSL transformation files should follow this structure:: General report to test the reports Report for the TestReports plugin. ORS Team http://theobjects.com info@theobjects.com Object Research Systems (ORS), Inc.
460 Ste-Catherine Ouest, suite 600, Montréal, Québec, Canada, H3B 1A7
Object Research Systems (ORS), Inc. All rights reserved 2021. Oct 05 2021 17:00 1.0.0 fa032a43262111ecaba7f8ac6585ab6e
TestReports_2a03860d260411ecaba4f8ac6585ab6e General 1.0 Some text to be put in the LaTeX document.
Node ^^^^^^^^^^^^^^^^^^^^^^^ This node contains the description of this XSL transformation (for example, what kind of report it produces). This node contains also the node ````, used to identify uniquely this transformation. .. warning:: The node ```` should be unique amongst all XSLT files found by the application. Node ^^^^^^^^^^^^^^^^^^ This node describes the supported data. Each ```` child node should contain this set of nodes: - ````: name of the plugin that generated the data; - ````: name of the report kind; - ````: report version number. Validation of the transformation of a list of XML data files through an XSLT file can be done by calling the method :meth:`ORSServiceClass.xslt.xsltutil.XSLTUtil.isXSLTransformationSupported`. An XSL transformation is considered as supported if any of the ```` node found in the XSL file matches any ```` node found in the XML data file. Node ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This node contains the actual processing of the transformation of the XML data into a LaTeX document. Tutorials --------- Here are some links to tutorials and references about XPath and XSLT: - `XPath Tutorial `_ - `XSLT Tutorial `_ - `XSLT Elements Reference `_ - `XSLT, XPath, and XQuery Functions `_ - `XML Path Language (XPath) Version 1.0 `_ - `XSL Transformations (XSLT) Version 1.0 `_ .. TODO Documentation video on making reports: - plugin to generate a report (plugin development, XML data structure, LaTeX file, XSL development) from the analysis of a dataset - activate logging in this plugin, make a macro to generate a single report from a dataset - macro builder to batch reports over a set of datasets in folders - use report generator to do summary report (XSL development from existing XML files) - in plugin, add (logging) method to take a list of report files, generate a XML report file of summary plot, add this file in list of XML files to use and send it to report generator with XSL adapted to include summary plot - to generate/debug an XSL file: -- make a working LaTeX example -- look at tutorial/reference pages (XPath, XSLT, references) on W3Schools -- generate the merged XML file (as it would be provided to the XSL transform file) with XSLTUtil.generateMergedXMLs or OrsReportGenerator/exportCurrentInputFilesAsMergedXML -- use the JetBrains IntelliJ IDEA (Community Edition), Visual Studio, or PyCharm (with XSLT plugins) to debug XSL by using breakpoints -- output file may be viewed in TeXnicCenter for syntax or comparison to generate the PDF -- use report generator to perform the full task of generating the report -- break in XSLTUtil/generatePDFFromXML code to see the output log of the LaTeX compilation and run it again - output (in documentation web page) should contain: -- plugin; -- macro (single dataset); -- macro (batch); -- XSL (single dataset); -- XSL (summary); -- datasets. - how to debug when the PDF is not generated because of an error in the LaTeX file? -- break in PyCharm to keep the temporary files alive (XML data, images)(.tex, .log) -- in Notepad++, examine the .log file for errors, look in .tex file at corresponding line; -- copy text from .tex file in a temporary project in TeXnicCenter an run. Image files are put with their absolute path (in a temporary folder), so the temporary folder should be kept alive, or the contents may be copied and all paths in .tex file changed for the new path -- LaTeX compilation .log file shown in PyCharm console -- instead of making a temporary directory for the data (plugin side), the XML data and images files may be generated directly in the output folder. -- Mechanism (class variable CLEANUP_TEMPORARY_FILES=True in XSLTUtil, changeable in startup_script or from ScriptRunner) to keep the temporary folders (the one from the plugin and the one of the LaTeX generated files), so that the LaTeX file can be generated again with the .xml and image files still alive in their temporary folder and the LaTeX log file showing the full output.