[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|