LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML report - Format Colors

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 

 

 

 

 

 

 

0 Kudos
Message 1 of 12
(661 Views)

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.

 

0 Kudos
Message 2 of 12
(658 Views)

Just example, how it looks with VSCode and TODO Highlighter v2:

 

Screenshot 2024-04-09 13.49.14.png

 

The Settings looks like:

 

Screenshot 2024-04-09 13.51.03.png

0 Kudos
Message 3 of 12
(635 Views)

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 ? 

0 Kudos
Message 4 of 12
(625 Views)

If you need to get this within LabVIEW, then you can use snippet like this:

Colorizer.png

Message 5 of 12
(614 Views)

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:

Colorizer2.png

Then looks like this:

Screenshot 2024-04-10 14.48.29.png

 

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):

Screenshot 2024-04-10 15.07.15.png

OK, now you can open XML directly in Edge (drag and drop file to URL), and enable this option:

Screenshot 2024-04-10 15.09.43.png

You need to do this only once, you can select an Option "open this file in this mode forever":

Screenshot 2024-04-10 15.12.23.png

And now we have our conditionally colorized and nicely formatted XML report:

Screenshot 2024-04-10 15.14.23.png

Hopefully will be useful for someone else.

Andrey.

Message 6 of 12
(530 Views)

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 

0 Kudos
Message 7 of 12
(474 Views)

@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:

Screenshot 2024-04-11 12.19.33.png

 

The next problem is that you have 20 items in parser, but only 3 in colorizer:

Screenshot 2024-04-11 12.21.13.png

You don't need 20 here, but you need both Passed and Failed strings, otherwise "Failed" will be not colorized:

 

Screenshot 2024-04-11 12.25.23.png

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:

Screenshot 2024-04-11 12.28.33.png

Then it will work again:

Screenshot 2024-04-11 12.29.08.png

I can't run your "Write_XML_Report", because of missing SubVIs:

Screenshot 2024-04-11 12.29.59.png

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:

Screenshot 2024-04-11 12.32.04.png

To display XML formatted you forgot here XSL

Screenshot 2024-04-11 12.33.56.png

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:

Screenshot 2024-04-11 12.36.46.png

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.

Message 8 of 12
(464 Views)

Ah, and two separate arrays are not necessary, colors and start/stop indexes can be combined, of course:

Screenshot 2024-04-11 14.02.23.png

Changed VI in attachment, sorry, forgot to attach to the previous comment.

Message 9 of 12
(448 Views)

And just one more thing. This will obviously not work for you as expected:

Screenshot 2024-04-11 14.40.35.png

Output string will not contain color info. To do this in SubVI you should pass reference instead of value:

snippet3.png

Then it will work if used like this:

Screenshot 2024-04-11 14.39.21.png

Message 10 of 12
(437 Views)