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

Re: 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 finally figured it out. In case anyone is interested, here is a snippet from my WebTestReport.xsl:

Basically, anytime it finds the string "lineBreak," it will insert a <br/>.

    <!-- Special representation for the <testInfo .../> steps if any -->
    <xsl:template name="displayTestInfo">
      <xsl:if test=".//step[@taskName = 'testInfo']">
        <div class="testInfo">
          <div class="testInfoTitle">Test info</div>
          <ul class="testInfo">                    
            <xsl:for-each select=".//step[@taskName = 'testInfo']">
              <xsl:choose>
                <xsl:when test="parameter[@name = 'type' and @value='reportLink']">
                  <li>
                    <b>
                      <xsl:value-of select="parameter[@name = 'type']/@value"/>
                      <xsl:text>:&space;</xsl:text>
                    </b>
                    <a>
                      <xsl:attribute name="href">
                        <xsl:value-of select="parameter[@name = 'info']/@value"/>
                      </xsl:attribute>
                      <xsl:text>There was an error. Click this to see the page.
                        <!-- <xsl:value-of select="parameter[@name = 'nested text']/@value"/> -->
                      </xsl:text>
                    </a>
                  </li>
                </xsl:when>
                <xsl:otherwise>
                    <li>
                      <b>
                        <xsl:value-of select="parameter[@name = 'type']/@value"/>
                        <xsl:text>:&space;</xsl:text>
                      </b>
                      <xsl:call-template name="SplitText">
                        <xsl:with-param name="inputString" select="parameter[@name = 'info']/@value"/>
                      </xsl:call-template>
                    </li>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </ul>
        </div>
      </xsl:if>
    </xsl:template>

    <xsl:template name="SplitText">
      <xsl:param name="inputString"/>
      <xsl:choose>
        <xsl:when test="contains($inputString, 'lineBreak')">
          <xsl:value-of select="substring-before($inputString, 'lineBreak')"/>
          <br/>
          <xsl:call-template name="SplitText">
            <xsl:with-param name="inputString" select="substring-after($inputString,'lineBreak')"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <xsl:when test="$inputString = ''">
              <xsl:text></xsl:text>
            </xsl:when>
            <xsl:otherwise>
              <p>
                <xsl:value-of select="$inputString"/>
                <xsl:text> </xsl:text>
              </p>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>


Kelcy Monday


A Vander <avander_be@...>
Sent by: webtest-admin@...

07/01/2009 11:26 AM
Please respond to
webtest@...

To
webtest@...
cc
Subject
Re: [Webtest] WebTestReport.xsl -- add template to parse out line breaks for <testInfo> step






Maybe this will get you started, I just added an apply-templates to reprocess
the testInfo step after the standard one so I can catch the info an add
something to the report, see the lines with "myTurn".

Piece of WebTestreport.xsl ( I'm using wt 3.0):
...
   <!-- Special representation for the <testInfo .../> steps if any -->
   <xsl:template name="displayTestInfo">
       <xsl:if test=".//step[@taskName = 'testInfo']">
           <div class="testInfo">
               <div class="testInfoTitle">Test info</div>
               <ul class="testInfo">
                                <xsl:for-each select=".//step[@taskName = 'testInfo']">
                                                                           <li>
                                                                               
                                                                                   <xsl:value-of select="parameter[@name =
'type']/@value"/>
                                                                                   <xsl:text>:&space;</xsl:text>
                                                                               
                                                                               <xsl:value-of select="concat(parameter[@name =
'info']/@value, parameter[@name = 'nested text']/@value)"/>
                                                                           </li>
                                </xsl:for-each>
                               
                                <xsl:apply-templates select=".//step[@taskName =
'testInfo']" mode="myTurn"/>
               </ul>
           </div>
       </xsl:if>
   </xsl:template>
   
   <xsl:template match="step[@taskName = 'testInfo']" mode="myTurn">
                <p>myTurn to say something about testinfo: <xsl:value-of
select="parameter[@name = 'type']/@value" /></p>
   </xsl:template>
...

Hope this helps,

Avander
--
View this message in context:
http://www.nabble.com/WebTestReport.xsl----add-template-to-parse-out-line-breaks-for-%3CtestInfo%3E-step-tp24272543p24291785.html
Sent from the WebTest mailing list archive at Nabble.com.

_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

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