|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XSL stylesheet issue (newbie)
Thank you to all of you for this great feedback! I'll let you know how I get
along on Monday.
Freundliche GrC<Ce | Best regards
Frank Dissinger
Documentation Manager
..........................................
CGS ORIS GmbH
frank.dissinger@xxxxxxxxxxxx | www.cgs-oris.com
Kettelerstrasse 24 | 63512 Hainburg | Germany
Phone +49 6182 9626-0 | Fax +49 6182 9626-99
Commercial register: Offenbach, HRB no. 21495
Managing directors: Bernd RC<ckert, Christoph Thommessen
b
-----------------------------------------------------------------------------
------------------------
-----UrsprC<ngliche Nachricht-----
Von: Frank Dissinger <frank.dissinger@xxxxxxxxxxxx>
Gesendet: Donnerstag, 17. Oktober 2024 19:21
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: XSL stylesheet issue (newbie)
Hello everyone,
The stylesheet below is supposed to add a unique 'id' attribute named
'tocref001', 'tocref002' etc. to all <h2>, <h3> and <p class="rn_heading">
elements which are descendants of an element with an 'id' attribute named
'rn_release_notes'. The script runs without any errors, but does not add any
IDs.
I admit that I have little to no knowledge of XSLT. ChatGPT was my friend. But
I have created a small HTML file and an XSL stylesheet with slightly simpler
XPath expressions which works fine. But it does not work with a more complex
HTML file. I have attached such a file to this message. A colleague who is a
software developer tried to debug the stylesheet with Visual Studio, but
without success.
The purpose of this script, when finished, is to create a Table of Contents
for an HTML file. The current state of it is only to add hyperlink targets to
the relevant headings.
Any help is greatly appreciated.
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Output settings for HTML5 -->
<xsl:output method="html"
encoding="UTF-8"
indent="yes"/>
<!-- Identity template to copy all elements and attributes -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- Adding id=toc001 attributes to headings to create hyperlink targets for
the TOC --> <xsl:template match="*[@id='rn_release_notes']//h2 |
*[@id='rn_release_notes']//h3 |
*[@id='rn_release_notes']//p[@class='rn_heading']">
<xsl:variable name="id">
<xsl:number level="any" count="*[@id='rn_release_notes']//h2 |
*[@id='rn_release_notes']//h3 |
*[@id='rn_release_notes']//p[@class='rn_heading']" format="000"/>
</xsl:variable>
<xsl:copy>
<xsl:attribute name="id">tocref<xsl:value-of
select="$id"/></xsl:attribute>
<xsl:apply-templates select="@*[name() != 'id']"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
|
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
|

Cart








