« Return to Thread: WebTestReport.xsl -- add template to parse out line breaks for step

WebTestReport.xsl -- add template to parse out line breaks for <testInfo> step

by Kelcy Monday-2 :: Rate this Message:

Reply to Author | View in Thread

I would like to parse out and render line breaks in string that is passed through the <testInfo> step.  I have a basic idea of how to do this, but I keep getting stuck on implementation.

Here is the code that I have:

        <xsl:template match="parameter[@name = 'type' and @value='reportSettings']" mode="replaceLineBreaks"
                      name="replaceLineBreaks">
          <xsl:param name="string" select="parameter[@name = 'info']/@value" />
          <xsl:choose>
            <!-- if the string contains a line break... -->
            <xsl:when test="contains($string, '&#xA;')">
              <!-- give the part before the line break... -->
              <xsl:value-of select="substring-before($string, '&#xA;')" />
              <!-- then a br element... -->
              <br />
              <!-- and then call the template recursively on the rest of the
                   string -->
              <xsl:call-template name="replaceLineBreaks">
                <xsl:with-param name="string"
                                select="substring-after($string, '&#xA;')" />
              </xsl:call-template>
            </xsl:when>
            <!-- if the string doesn't contain a line break, just give its
                 value, followed by a br element -->
            <xsl:otherwise>
              <xsl:value-of select="$string" /><br />
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>

My biggest problem is figuring out where to put the template and where to call it.  I also am not sure if my match string is appropriate.

Kelcy Monday

 « Return to Thread: WebTestReport.xsl -- add template to parse out line breaks for step