This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: newbie: problems computing output from variables


> 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:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]