NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

stylesheet array syntax

Solved!
Go to solution

I have created a script that stores information into an array.  I want to print out each index of the array in my report, but in the header.  Does anyone know the syntax I would need to access the array elements from the stylesheet?

[DL]
0 Kudos
Message 1 of 17
(4,400 Views)

Hi,

 

I believe this link tells how you can edit parts of the header in the report. Let me know if this helps out. Have a great day!

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 2 of 17
(4,381 Views)

How do i access the elements of an array in the sequence file and include it in the report?  I need to know what the "@XXX" is for the array element i'm trying to print out.

[DL]
0 Kudos
Message 3 of 17
(4,354 Views)

DL,

 

The following is copied from a KB that is still in work and not online yet.

 

1. Define a variable with the same name as the XML tag that you've defined in your xsl.  Both string and number variables work with the XML generation. Parameters work as the best variables as you often want to write to these values from other locations in your code.
2. Create an ActiveX Action step. The reference in will be the location of your variable.  Ex. Locals, Parameters, FileGlobals, (or if in a container: Parameters.MyContainer)
3. The Object Class is a PropertyObject and you are calling the GetXML Method.  Store the return value in a variable (Locals.XML) and in the next step we will add that variable to the header.  Pass 0x95, 0, <XML Tagname>, Parameters.ReportOptions.NumericFormat as your values in (again where the XML Tagname is what you've defined as your variable in TestStand and the tag in the xsl document).
4. Add a statement step with Parameters.ReportHeader += Locals.XML to add the generated XML code to the header.

 

The format to access the array will likely be <xsl:value-of select="Prop[@Name='myArray']/Prop[@Name='myArray']/Value[@ID='[2]']"/>

 

Let us know if you have more questions about setting this up in TestStand or XSL.

National Instruments
Message 4 of 17
(4,319 Views)

Where do I pass in the Parameters.ReportHeader and Parameters.ReportOptions.NumericFormat from?

[DL]
0 Kudos
Message 5 of 17
(4,305 Views)

DL,

 

I apologize, I left out the most important information. This should be done in the ModifyReportHeader callback. You are going to want to override that callback with these steps. That callback should have those parameters specified.

National Instruments
Message 6 of 17
(4,295 Views)

I included my steps in the ModifyReportHeader call back and i can verify that the Parameters.ReportHeader is being populated with my data, but still nothing is outputting in the report.  I've used the following xsl statement to read each element of my array.

 

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[0]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[1]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[2]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[3]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[4]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[5]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[6]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[7]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[8]']"/>

<xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[9]']"/>

[DL]
0 Kudos
Message 7 of 17
(4,284 Views)

Were you able to modify the report header to display a section for the array information? I mean do you have a field in the report that is either failing to display the array element or displaying the entire array? If not, follow the guidelines in the help topic Customizing the UUT Report Header.

 

National Instruments
Message 8 of 17
(4,276 Views)

I've modified the XSL to display the report header fields i want to show.  for example,

 

  • UUT Name:

  • UUT Part Number:

  • UUT Serial Number:
  •  

    I'm having trouble displaying the array element for each of these items.  the data i want to print to my report is contained in a userInput[] array.

    [DL]
    0 Kudos
    Message 9 of 17
    (4,273 Views)

    The code you posted looks correct. Let me walk back through it all again in different words and maybe we can find the problem.

     

    In TestStand you will need to add the ModifyReportHeader callback. In this callback add two steps. The first is an ActiveX action step with the following settings:

     

    Automation Server: NI TestStand API 4.2       (or whatever version you are using)

    Object Reference: Locals                              (or the container you placed your array in)

    Object Class: Property Object

    Call Method (selected from drop down): GetXML

     

    Parameters:

    Return Value: Locals.XML

    GenerationOptions: 0x95

    InitialIndentation: 0

    DefaultName: "userInput"

    formatString: Parameters.ReportOptions.NumericFormat

     

     

    Assuming you are using either expand.xsl or report.xsl. In the XSL file you need to insert the following lines of code just above the comment with the CREAT_UUTHEADER_INFO tag:

     

    Note: I would recommend creating a new xsl file copied from the one you would like to edit. You can then select to use this file in the report configuration options.

     

     

              <TR>
                <TD NOWRAP="NOWRAP">
                  <B>
                    <LI> Array Value 0:</LI>
                  </B>
                </TD>
                <TD>
                  <B>
                    <xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[0]']"/>
                  </B>
                </TD>
              </TR>
              <TR>
                <TD NOWRAP="NOWRAP">
                  <B>
                    <LI> Array Value 1:</LI>
                  </B>
                </TD>
                <TD>
                  <B>
                    <xsl:value-of select="Prop[@Name='userInput']/Prop[@Name='userInput']/Value[@ID='[1]']"/>
                  </B>
                </TD>
              </TR>

     

    Continue this on for all new lines of the header you need to add.

     

    National Instruments
    Message 10 of 17
    (4,254 Views)