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: Two versions of variable expression


>    I posted this question last week already but somehow it never
> showed up on the list. So here is my question again. Consider the
> following two expressions:
>
> <xsl:variable name="cell">
>   <xsl:value-of select="following-sibling::*[position() =
> 1]/text[@name=$colname] |
>                         following-sibling::*[position() =
> 1]/select[@name=$colname] |
>                         following-sibling::*[position() =
> 1]/checkbox[@name=$colname] |
>                         following-sibling::*[position() =
> 1]/label[@name=$colname]"/>
> </out:variable>

The select expression constructs a node-set, and the <xsl:value-of> outputs
the string value of the first node in this node-set ignoring the rest. The
final result is a result tree fragment containing a single text node. Is
this what you want?

>
> <xsl:variable name="cell" select="following-sibling::*[position() =
> 1]/text[@name=$colname] |
>                            following-sibling::*[position() =
> 1]/select[@name=$colname] |
>                            following-sibling::*[position() =
> 1]/checkbox[@name=$colname] |
>                            following-sibling::*[position() =
> 1]/label[@name=$colname]"/>
>
> The second expression allows me to work with $cell, the first
> expression
> doesn't.
> In the case of the first expression I get an error message
> even though I know that he
> node I'm interested in exists. Why is that?

Perhaps because the end tag </out:variable> does not match the start tag
<xsl:variable>.

> Unfortunately, I
> cannot use the
> second
> expression because I have to add some if-statement into the
> whole business.
>

There's a way around that with node-sets: instead of

if ($a) then $b else $c

write

 $b[$a] | $c[not($a)]

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]