xsl-list
[Top] [All Lists]

Re: [xsl] Add id to next element

2022-05-19 20:34:46
Hi Graydon,

What's wrong with

<xsl:template match="section">
    <xsl:copy>
      <xsl:apply-templates select="@*" mode="#current" />
      <xsl:attribute name="id"
        select="(preceding-sibling::*[1][self::target]/@refid,generate-id(.)) 
=> head()" />
      <xsl:apply-templates mode="#current" />
    </xsl:copy>
</xsl:template>

I normally use (expr1, expr2)[1] as an if-then-else for expressions evaluating 
to 0 or 1 node, but that arrow syntax is pretty neat. I should start using it.

 - Chris
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--


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