Re: [xsl] XSL If Statement - Repost

Subject: Re: [xsl] XSL If Statement - Repost
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 22 Aug 2008 14:57:38 +0100
The XML and XSL that you posted is so fragmented it is very hard to
help. It is much better to post small but well formed examples.


<xsl:for-each select="topic/detail">

That processes all the detail grandchildren of the current element.

<xsl:if test="$matrix=1">

That would test if the variable matrix had value 1 (as this test doesn't
depend on the current detail node then it would test either true for all
items or false for all items, depending on the value of matrix.


<xsl:if test="matrix=1">

That would test if the string value of the matrix element that is a
child of the current detail element if coerced to a number had value 1.
This test would have potentially different results for each item in teh
sequence selected by the xsl:for-each.

<xsl:if match=".[matrix=1]">
That is a syntax error, xsl:if does not have a match attribute, and so
the stylesheet would produce no results.


given 
<topic>
    <detail>
         <matrix>1</matrix>

and assuming that the current node is /

then it would appear that you want

<xsl:for-each select="topic/detail">
<xsl:if test="matrix=1">
...

or more simply
<xsl:for-each select="topic/detail[matrix=1]">

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread