xsl-list
[Top] [All Lists]

Re: Following-sibling node test

2005-02-20 13:49:38
Tempore 21:42:55, die 02/20/2005 AD, hinc in xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Maria Amuchastegui <mamuchastegui(_at_)to(_dot_)epost(_dot_)ca>:

I am trying to output a list of all 'ref' attributes for which the
corresponding 'HTML' element is empty. For example, given the following xml
data, I would want to  output ['2','3','4','5']. The final element in the
list should *not* be followed by a comma. I am tying to use the
following-sibling node test but it's not working. How can I test for these two conditions (HTML element is not empty, and is last item in list)?


By using a predicate:

<xsl:template name="SectionNumbers">
  <xsl:for-each select="/Content/Section[not(HTML = '')]">
           <xsl:text>'</xsl:text>
           <xsl:value-of select="@ref"/>
           <xsl:choose>
                        <xsl:when test="following-sibling::*[not(HTML = '')]">
                                 <xsl:text>',</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                                 <xsl:text>'</xsl:text>
                        </xsl:otherwise>
           </xsl:choose>
  </xsl:for-each>
</xsl:template>

regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
"Et ipsa scientia potestas est"  - Francis Bacon , Meditationes sacrae

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>