04-09-2024 05:35 AM
Hi team ,
I want to modify the XML report particular strings to be formatted .
The Test XML report contains the result of each test case and its parameters. ( Test pass / Test Fail )
Need to modify these ( Test Pass / Fail ) strings to format like Bold characters or different colored strings .
Is Any Specific toolkit available or other ways to crack on this .
Kindly guide me on this . Attached Sample report
04-09-2024 05:43 AM
It depends from the viewer you're using to display XML.
Theoretically you can adjust colorizing schema with some advanced editors, like notepad++, UltraEdit, VSCode, or similar.
04-09-2024 06:54 AM
04-09-2024 07:35 AM
Hi Andrey ,
Yes i want this kind of format only , but these needs to be done by programmatically .
I am working on ATE tester , that automatically creates a report in the backend when all test case sequences are over . That's why i asked for any specific toolkit available already in VI Package manager or any methods programmatically ?
04-09-2024 08:47 AM
If you need to get this within LabVIEW, then you can use snippet like this:
04-10-2024 08:18 AM - edited 04-10-2024 08:22 AM
Its me again. Two small updates.
First of them, small correction for previous snippet (was small race condition and kind of "Rube Goldberg Code". In addition, we can easily highlight XML Tags, something like this:
Then looks like this:
The second part - I was contacted by Mrtechie through private message and he asked me how to do colorization in Edge browser. After some experiments with XSLT I found following.
At the beginning of our XML file we should add link to the XSL Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<TestData>
<Data>
<Test>*** Battery Charging... ***</Test>
<Status>--- Test Passed ---</Status>
<Measured>To be measured...</Measured>
<LowerLimit>3.1</LowerLimit>
<HigherLimit>4.5</HigherLimit>
</Data>
<Data>
<Test>*** 3.3V Test ***</Test>
<Status>--- Test Failed ---</Status>
<Measured>To be measured...</Measured>
<LowerLimit>0.1</LowerLimit>
<HigherLimit>0.5</HigherLimit>
</Data>
<Data>
<Test>*** Check SIM Card... ***</Test>
<Status>--- Test Passed ---</Status>
<Measured>To be measured...</Measured>
<LowerLimit>5.5</LowerLimit>
<HigherLimit>7.7</HigherLimit>
</Data>
</TestData>
Now the test.xsl file with conditional formatting should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="TestData/Data">
<xsl:if test="Status='--- Test Failed ---'">
<div style="background-color:red;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="Test"/> :: </span>
<xsl:value-of select="Status"/>
</div>
</xsl:if>
<xsl:if test="Status='--- Test Passed ---'">
<div style="background-color:green;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="Test"/> :: </span>
<xsl:value-of select="Status"/>
</div>
</xsl:if>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<p> <xsl:value-of select="Measured"/> </p>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<span> Lower Limit: </span> <xsl:value-of select="LowerLimit"/>
<span> Higher Limit: </span> <xsl:value-of select="HigherLimit"/>
</div>
</xsl:for-each>
</body>
</html>
(Full XSLT guide is offtopic, lot of tutorials and books are available)
To be displayed in Edge I was need to perform some tricks.
First of them, create shortcut on the desktop to start Edge with --allow-file-access-from-files param as shown:
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" --allow-file-access-from-files
Now enable Internet Explorer mode (IE mode) button in your toolbar for Edge.
You can access the setting here: edge://settings/appearance#CustomizeToolbar.
Just enter this as URL, then enable this option (sorry for German screenshot):
OK, now you can open XML directly in Edge (drag and drop file to URL), and enable this option:
You need to do this only once, you can select an Option "open this file in this mode forever":
And now we have our conditionally colorized and nicely formatted XML report:
Hopefully will be useful for someone else.
Andrey.
04-11-2024 05:05 AM
Hi Andrey ,
Thanks for the clarifications .
I followed in the edge browser changed the settings and not reflected. Attached Screenshot and XML report .
I was struck in the program too . I had 20 number of testcases . So i inserted Your program (colorizer2) as a subvi in the main vi (Write_XML_Report) to generate reports , there was no change in that existing report except the bold format of strings . Can you guide me on this
04-11-2024 05:42 AM
@Mrtechie wrote:
Hi Andrey ,
Thanks for the clarifications .
I followed in the edge browser changed the settings and not reflected. Attached Screenshot and XML report .
I was struck in the program too . I had 20 number of testcases . So i inserted Your program (colorizer2) as a subvi in the main vi (Write_XML_Report) to generate reports , there was no change in that existing report except the bold format of strings . Can you guide me on this
OK, step by step.
First problem is in Test Result Colour_Format1.vi — your strings are not matched:
The next problem is that you have 20 items in parser, but only 3 in colorizer:
You don't need 20 here, but you need both Passed and Failed strings, otherwise "Failed" will be not colorized:
In general your idea with building colors from the loop is not bad, but I would like to recommend to do it something like this probably, so the colors will be near strings in cluster:
Then it will work again:
I can't run your "Write_XML_Report", because of missing SubVIs:
But would to recommend to group your data blocks as was shown above in my XML example, because currently you have "plain list" of the tags, but better to have something like that:
To display XML formatted you forgot here XSL
This is a reason why XML displayed in "RAW" format.
But XSL is not enough, you should group your data into blocks, otherwise XSL for-each iterator here will not work:
May be it is possible to get output colorized with your "plain list", but I'm not so experienced with XSLT. Better to group these data blocks logically.
04-11-2024 07:08 AM
Ah, and two separate arrays are not necessary, colors and start/stop indexes can be combined, of course:
Changed VI in attachment, sorry, forgot to attach to the previous comment.
04-11-2024 07:43 AM
And just one more thing. This will obviously not work for you as expected:
Output string will not contain color info. To do this in SubVI you should pass reference instead of value:
Then it will work if used like this: