Re: [xsl] Xpath problem?

Subject: Re: [xsl] Xpath problem?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Jun 2006 11:19:27 -0400
Seth,

In what context is the allMaxTime template being called? (What does that for-each wrapper look like?)

If not inside the source document, the parameter value "/testResults/*/@t" will likely be an empty node set. The same path could work fine elsewhere if the context is in your primary source document.

That's just a stab in the dark: an answer more likely to be correct, but less likely to be helpful, is that the problem appears to be in the part of the code you haven't shown us.

Cheers,
Wendell

At 09:35 AM 6/28/2006, you wrote:
I am using an integration of Apache Ant and Apache JMeter that comes
with xsl files to process the results of a JMeter test. Knowledge of
either of these programs shouldn't be necessary to answer my question.

Almost the entire report (html format) generates correctly, except for
some instances where two specific templates are called, with preselected
nodes passed in.

Here are some snippets of the code:
...
<xsl:variable name="allMaxTime">
  <xsl:call-template name="max">
    <xsl:with-param name="nodes" select="/testResults/*/@t" />
  </xsl:call-template>
</xsl:variable>
...
<xsl:template name="max">
  <xsl:param name="nodes" select="/.." />
  <xsl:choose>
    <xsl:when test="not($nodes)">NaN</xsl:when>
    <xsl:otherwise>
      <xsl:for-each select="$nodes">
        <xsl:sort data-type="number" order="descending" />
        <xsl:if test="position() = 1">
          <xsl:value-of select="number(.)" />
        </xsl:if>
      </xsl:for-each>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
...
----------------------------------------------------------------------
And the xml looks like this:
<testResults version="1.2">
  <httpSample t="290" lt="0" ts="1151499119860" s="true"
              lb="ATO Summit Home" rc="302" rm="Moved Temporarily"
              tn="Thread Group 1-1" dt="">
    <assertionResult>
      <failure>false</failure>
      <error>false</error>
    </assertionResult>
  </httpSample>
...
</testResults>

The problem is, even though i have multiple entries of these
httpSamples, the result of the "max" template always is NaN, even though
a max value should be returned.

If I take the for-each loop outside the template, and run it without
calling the template, it works fine, and the select="/testResults/*/@t"
is used in other places in the XSL that work.

If anyone can tell me what the error is, and what the code should like
like instead, I would be very grateful.

Seth

Current Thread