xsl-list
[Top] [All Lists]

Re: [xsl] Add id to next element

2022-05-19 22:18:08
On Fri, May 20, 2022 at 12:18 AM Graydon graydon(_at_)marost(_dot_)ca
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

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 am assuming XSLT 3, here, but that should be a fairly safe assumption
these days.

Thank you for the solution.  Yes I am using XSLT 3.0 (Saxon EE 9.8 in
Oxygen XML Editor 21.1), but haven't really made any special use of
the 3.0 features.  I don't know the arrow syntax you have used.  WIll
look it up in the spec.

Regards,
Raghavendra.
--~----------------------------------------------------------------
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>