LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML report - Format Colors

Hi Andrey , 

 

i have added your modified "test result format color2 " program in main program . Pretty print not worked in LabVIEW.

 

Attached  programs  here for your better clarification. I have followed this method of using "Helper_Add New XML Tag Parser.vi " for XML report creation in backend ..Hope you will find the real issue this time . 

 

Even some other better method of your suggestion of creating XML also welcome from you 🙂 . i will stick to that . i am not a expert in handling XML & parsing . 

 

 

0 Kudos
Message 11 of 12
(143 Views)

Hi again! One more round, you still miss something.

First of them, you can't format and "colorize" in your own way the XML displayed in Browser without StyleSheet. XML deliver the Data, XSL StyleSheet delivers formatting rules and colors.

Here how you do it in LabVIEW:

At the beginning you should attach your Stylesheet, let name it "Colors.xsl":

Screenshot 2024-04-15 12.43.40.png

by calling Create Processing Instructions:

Screenshot 2024-04-15 12.44.43.png

This will append the string "<?xml-stylesheet type="text/xsl" href="Colors.xsl" ?>", to the beginning of your XML which you missing currently.

Next, you should "group" your data into the blocks, I added one more level here into your code:

Screenshot 2024-04-15 12.46.50.png

Inside is just one more child:

Screenshot 2024-04-15 12.50.04.png

In general you exactly the same constructions already in your "helper", so should be no problem.

This will split your data from plain list to the "Data" blocks:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<?xml-stylesheet type="text/xsl" href="Colors.xsl"?>
<TestData>

  <Data>
    <S.no>1</S.no>
    <TestcaseName>*****Sample test 0*****</TestcaseName>
    <Status>--- Test Failed ---</Status>
    <Measured>To be measured...</Measured>
    <LowerLimit>#Data1#</LowerLimit>
    <HigherLimit>#Data2#</HigherLimit>
  </Data>

  <Data>
    <S.no>2</S.no>
    <TestcaseName>*****Sample test 1*****</TestcaseName>
    <Status>--- Test Passed ---</Status>
    <Measured>To be measured...</Measured>
    <LowerLimit>#Data1#</LowerLimit>
    <HigherLimit>#Data2#</HigherLimit>
  </Data>

  <Data>
    <S.no>3</S.no>

 

Minor change here, you still have strings mismatch, they should be the same:

Screenshot 2024-04-15 12.53.41.png

From architecture point of view better do not "spread" hard-coded constants across the code, but store your Pass/Fail strings in one place (functional global, for example), then reuse on different places. They are you "colorizing" tokens, in general.

 

Well, now very important point - you should save TWO files - one is your XML, and another one is stylesheet on SAME place:

Screenshot 2024-04-15 12.57.40.png

In general the path to Colors.xls could be different, but then you should provide it at the beginning, so the href at the beginning of your XML will point to the correct file "<?xml-stylesheet type="text/xsl" href="Colors.xsl" ?>". Currently it is just "Colors.xsl" - assumed that will be loaded from the same location where XML is located.

 

You may be confused with "Pretty Print" method:

Screenshot 2024-04-15 13.00.49.png

And may think that "Pretty" means "with beautiful colors". No, "Pretty Print" means that the XML will be stored with indents and line feeds, nothing more. Save file without pretty print will store XML in "one line" without "formatting". But again, the colors, are not included here, they coming from separate XSL file.

 

OK, we are almost done. One small thing here - you have race condition in your code between terminal and property node. First write text to terminal, and only then call the coloriuzer, otherwise you have a risk to get empty or previous string here, this is how it could be corrected with two frames sequence:

Screenshot 2024-04-15 13.05.59.png

Finally I added Web Browser directly on the Front Panel, so you can see both methods of colorization on same place:

Screenshot 2024-04-15 13.07.00.png

And Result:

Screenshot 2024-04-15 13.09.09.png

Please do not confuse - these two methods of the colorization absolutely independent on each other. One perform colorization of the native LabVIEW string, and another one - colorization of XML with XLS StyleSheet.

Of course, you can open XML in the Edge in Explorer mode as was described above as usual.

Modified Demo project in the attachment.

 

Message 12 of 12
(92 Views)