This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: newbie: problems computing output from variables
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] newbie: problems computing output from variables
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Wed, 7 Feb 2001 12:49:08 -0000
- Reply-To: xsl-list at lists dot mulberrytech dot com
> My xsl (fumblings) are:
>
> <xsl:template match="/">
> ...
> <xsl:variable name="edits" select="id != edit_id"/>
> <xsl:variable name="editvase" select="$edits[position() < 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() < 6]">
<xsl:value-of select="question"/><br/>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list