Subject: [xsl] Re: <xsl:choose> or variable syntax incorrect? From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Fri, 26 Sep 2003 20:29:13 +0200 |
"Kathy Burke" <Kathy_Burke@xxxxxxxxx> wrote in message news:395DE57EA5BB7F4E952B7B89775350B5021E4208@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx > Same problem...but perhaps not the variable name issue? I've used the > current() syntax per Dimitri. Again, I'm trying to get a navy row if the > when test < 1 count, otherwise red. My xml source has three <Station> > elements, 2 have <Board> elements, 1 does not. However, all rows remain > navy. Any other comments on where I could be gong astray with the following? You could be going astray almost everywhere -- the code full of weird things to me. > > <xsl:template match="Station"> > > <xsl:variable name="boards" select="//Station[current()/@name]/Boards/Board" > /> ^^^^^^^^^^^^^^^^^ Are you sure you really *mean* this? This predicate is true if the current node has a "name" attribute (which is probably always the case). > <xsl:variable name="nboards" select="count($boards)" /> Because you're later testing to see if the count is less than one or not, you do not need the count at all. You just need whether the nodeset is empty or not -- this happens to be the expression $boards itself. > > <xsl:choose> > > <xsl:when test="$nboards < 1"> > <tr bgcolor="navy" valign="middle"> > <td><xsl:value-of select="@name"/></td> > </xsl:when> > > <xsl:otherwise> > <tr bgcolor="red" valign="middle"> > <td><xsl:value-of select="@name"/></td> > </xsl:otherwise> > > </xsl:choose> This test seems also very strange for generating rows with alternating properties, but you haven't at all explained the problem you're solving, so it is difficult to say that what you're doing is just wrong. I strongly recommend reading a good introductory book on XSLT -- e.g. Jeni's: "Beginning XSLT" for everyone, who needs to start understanding some basic concepts and techniques in writing XSLT transformations. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] <xsl:choose> or variable syn, Kathy Burke | Thread | RE: [xsl] Re: <xsl:choose> or vari, Kathy Burke |
[xsl] <xsl:choose> or variable syn, Kathy Burke | Date | RE: [xsl] Re: <xsl:choose> or vari, Kathy Burke |
Month |