xsl-list
[Top] [All Lists]

Re: [xsl] When first Node add a style in XSL

2008-05-16 07:23:04
Dan Acuff schrieb:
How do I put the proper test in for the first Node I encounter, add a
top border:?

    <xsl:template match="category">
        <xsl:choose>
            <xsl:when test="first::category">

Well, "first" is not an XPath axis. Maybe you're confusing XSLT and CSS?

If you want to test whether an element node is the first one in a given
node-set, you can proceed as follows:

<xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:output method="text"/>
  <xsl:template match="/">
    <xsl:apply-templates select="//Elm"/>
  </xsl:template>
  <xsl:template match="Elm[1]">
    <xsl:text>first one&#10;</xsl:text>
  </xsl:template>
  <xsl:template match="Elm">
    <xsl:text>not the first one&#10;</xsl:text>
  </xsl:template>
</xsl:transform>

Michael

--~------------------------------------------------------------------
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>