[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL stylesheet issue - part 2 (newbie)

Subject: Re: XSL stylesheet issue - part 2 (newbie)
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Oct 2024 06:41:33 -0000
Re:  XSL stylesheet issue - part 2 (newbie)
Frank, as Wendell pointed out, you seem to want two different processing
steps, if you want to do that in one XSLT stylesheet (instead of
chaining two) use modes


<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet B xmlns:xsl="http://www.w3.org/1999/XSL/Transform" B xpath-default-namespace="http://www.w3.org/1999/xhtml" B xmlns="http://www.w3.org/1999/xhtml" B version="3.0">

B  <!-- Output settings for XHTML -->
B  <xsl:output
B B B  method="xhtml"
B B B  encoding="UTF-8"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
B B B  indent="yes"/>

B <xsl:mode on-no-match="shallow-copy"/>

B <xsl:mode name="step2" on-no-match="shallow-copy"/>

B  <xsl:variable name="intermediary-result1">
B B B  <xsl:apply-templates/>
B  </xsl:variable>

B  <xsl:template match="/">
B B B  <xsl:apply-templates select="$intermediary-result1" mode="step2"/>
B  </xsl:template>

B  <!-- Adding a unique ID attribute using generate-id() to headings to
create hyperlink targets for the TOC -->
B  <xsl:template
B B B  match="*[@id='rn_release_notes']//h2 |
*[@id='rn_release_notes']//h3 |
*[@id='rn_release_notes']//p[@class='rn_heading']">
B B B  <xsl:copy>
B B B B B  <!-- Generating a unique ID for each element -->
B B B B B  <xsl:attribute name="id">
B B B B B B B  <xsl:text>tocref-</xsl:text>
B B B B B B B  <xsl:value-of select="generate-id()"/>
B B B B B  </xsl:attribute>
B B B B B  <!-- Copy the remaining attributes except "id", and apply
templates to children -->
B B B B B  <xsl:apply-templates select="@*[name() != 'id']"/>
B B B B B  <xsl:apply-templates select="node()"/>
B B B  </xsl:copy>
B  </xsl:template>

B  <!-- Template to generate the TOC -->
B  <xsl:template mode="step2" match="div[@id='rn_toc']">
B B B  <xsl:copy>
B B B B B  <xsl:apply-templates select="@*"/>
B B B B B  <xsl:apply-templates select="h1"/>

B B B B B  <!-- Insert the TOC after the <h1> element -->
B B B B B  <xsl:for-each select="//*[@id[starts-with(., 'tocref')]]">

B B B B B B B  <xsl:variable name="level">
B B B B B B B B B  <xsl:choose>
B B B B B B B B B B B  <xsl:when test="self::h2">1</xsl:when>
B B B B B B B B B B B  <xsl:when test="self::h3">2</xsl:when>
B B B B B B B B B B B  <xsl:when
test="self::p[@class='rn_heading']">3</xsl:when>
B B B B B B B B B  </xsl:choose>
B B B B B B B  </xsl:variable>

B B B B B B B  <p class="toclev{level}">
B B B B B B B B B  <a href="#{./@id}">
B B B B B B B B B B B  <xsl:value-of select="."/>
B B B B B B B B B  </a>
B B B B B B B  </p>

B B B B B  </xsl:for-each>
B B B  </xsl:copy>
B  </xsl:template>

</xsl:stylesheet>

On 22/10/2024 07:53, Frank Dissinger frank.dissinger@xxxxxxxxxxxx wrote:
Hi Wendell

Thank you for your reply. I have attached the input HTML file to this
message.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.