NI TestStand

Showing results for 
Search instead for 
Did you mean: 

Custom stylesheet, how to retrieve parts of seq file path

Go to solution

We are building a custom stylesheet for our specific needs that is based on the TR5_Horizontal stylesheet. The location that our sequence files are stored in have particular meaning (ex. part, rev, etc.) and I would like to extract those items to be displayed on the test report instead of the complete path to the sequence file.


I'm not really versed in XPath / XSLT so I've not gotten to far. I have tried some function that should help (like tokenize) however, it seems that I am limited to XSL 1.0.


I have found that I can get the path from the name attribute here: 

<xsl:when test="contains(@name,'#')">
<span style="margin-left:20px;font-size:70%;font-weight:bold;">
(<xsl:value-of select="substring-before(@name, '#')"/>)

If I want to split the path (ex. C:\..\..\..\part\rev\<testname>.seq) into the desired parts, how would I do this? 

0 Kudos
Message 1 of 2
Accepted by topic author pstestek

I was able to resolve my issue with the help of someone outside of this forum. The solution was to create a named template to parse the file path string:


 <xsl:template name="parse-path">

   <xsl:param name="text"/>

   <xsl:variable name="n" select="string-length(translate($text, translate($text, '\', ''), ''))"/>

   <xsl:if test="$n=2">



           <i><xsl:value-of select="substring-before($text, '\')"/>|</i>



   <xsl:if test="$n=1">



           <i><xsl:value-of select="substring-before($text, '\')"/>|</i>



   <xsl:if test="$n=0">



           <i><xsl:value-of select="substring-before($text, '.')"/></i>




   <xsl:if test="$n">

       <!-- recursive call -->

       <xsl:call-template name="parse-path">

           <xsl:with-param name="text" select="substring-after($text, '\')"/>





Message 2 of 2