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

View: New views
7 Messages — Rating Filter:   Alert me  

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

by Kelcy Monday-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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

by Michael Habbert-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kelcy,

I suggest you patch your local WebTestReport.xsl file (look inside your
WEBTEST_HOME directory).
We did it, to add a special handling for our ticket-system.

cheers

Michael

Kelcy Monday wrote:

> 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, ' ')">
>               <!-- give the part before the line break... -->
>               <xsl:value-of select="substring-before($string, ' ')" />
>               <!-- 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,
> ' ')" />
>               </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
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

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

by Kelcy Monday-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Michael,

I agree that the WebTestReport.xsl file should me modified. This is exactly what I am attempting. The code included in the original email is a snippet from my WebTestReport.xsl file, but I am having some issues getting the code to work.

What I need help with is getting my basic idea to from basic idea to proper implementation.

Thanks,
Kelcy Monday


Michael Habbert <michael@...>
Sent by: webtest-admin@...

06/30/2009 03:00 PM
Please respond to
webtest@...

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





Hi Kelcy,

I suggest you patch your local WebTestReport.xsl file (look inside your
WEBTEST_HOME directory).
We did it, to add a special handling for our ticket-system.

cheers

Michael

Kelcy Monday wrote:
> 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
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest


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

by Michael Habbert-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kelcy,

did you try:

<xsl:output method="html" encoding="utf-8"/>

I'm not so familiar with xslt, even though I did extend our
transformation-script once.

cheers,

Michael

Kelcy Monday wrote:

> Michael,
>
> I agree that the WebTestReport.xsl file should me modified. This is
> exactly what I am attempting. The code included in the original email is
> a snippet from my WebTestReport.xsl file, but I am having some issues
> getting the code to work.
>
> What I need help with is getting my basic idea to from basic idea to
> proper implementation.
>
> Thanks,
> Kelcy Monday
>
>
> [...]
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

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

by Kelcy Monday-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I tried using the UTF-8 encoding option and that didn't make any difference :(

Kelcy Monday


Michael Habbert <michael@...>
Sent by: webtest-admin@...

06/30/2009 03:41 PM
Please respond to
webtest@...

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





Hi Kelcy,

did you try:

<xsl:output method="html" encoding="utf-8"/>

I'm not so familiar with xslt, even though I did extend our
transformation-script once.

cheers,

Michael

Kelcy Monday wrote:
> Michael,
>
> I agree that the WebTestReport.xsl file should me modified. This is
> exactly what I am attempting. The code included in the original email is
> a snippet from my WebTestReport.xsl file, but I am having some issues
> getting the code to work.
>
> What I need help with is getting my basic idea to from basic idea to
> proper implementation.
>
> Thanks,
> Kelcy Monday
>
>
> [...]
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest


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

by A Vander :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

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

by Kelcy Monday-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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