RE: [xsl] newbie: problems computing output from variables

Subject: RE: [xsl] newbie: problems computing output from variables
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 7 Feb 2001 12:49:08 -0000
> My xsl (fumblings) are:
> <xsl:template match="/">
> ...
> <xsl:variable name="edits" select="id != edit_id"/>
> <xsl:variable name="editvase" select="$edits[position() &lt; 6]"/>
> <xsl:for-each select="/faqs/faq">
> <xsl:choose>
> <xsl:when test="$edits">
> <xsl:value-of select="$question"/><br/>
Your're setting $edits to a value: true if the root node has an <id> child
and an <edit_id> child with the same string value. It doesn't, so $edits is
always false.

Then you're trying to select those nodes in $edits whose position is less
than 6. But $edits is false, it doesn't contain any nodes, so the selection
is meaningless.

I think you wanted $edits to be an expression which is evaluated later:
that's not the way it works.

You don't need variables at all here, just:

<xsl:for-each select="faqs/faq[id!=edit_id][position() &lt; 6]">
  <xsl:value-of select="question"/><br/>

Mike Kay

 XSL-List info and archive:

Current Thread