[xsl] XSL stylesheet issue (newbie)

Subject: [xsl] XSL stylesheet issue (newbie)
From: "Frank Dissinger frank.dissinger@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Oct 2024 17:21:40 -0000
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>
COLOR TUNER Version 3.4 Release Notes B) CGS ORIS GmbH b 10/17/2024
=====================================================================

This file describes the additions, modifications and bug fixes in COLOR
TUNER Version 3.4.

Licensing
---------

COLOR TUNER Version 3.4 is license-protected and requires a new software
license. If there is a valid software service contract, the license is
free of charge and will be sent automatically.

System Recommendations
----------------------

We recommend the following computer equipment for optimum performance and
high throughput:

  * 

    Intel Core i7 6th generation or better

  * 

    16 GB of RAM or more

  * 

    500 GB SSD disk (system disk) or more

  * 

    Windows 10 or newer

Installation
------------

Certain programs may block the installation process. The process pauses
after extracting the installation files. In this case proceed as follows:

  1. 

    If the current version of Adobe Creative Cloud is installed, exit the
    Adobe Creative Cloud desktop app.

    Do this by selecting File > Exit Creative Cloud, then click Quit to
    stop all background processes.

  2. 

    Start Windows Task Manager and click the Details tab.

  3. 

    Right-click Setup.exe and select Analyze wait chain.

  4. 

    The process listed under Setup.exe is blocking the installation.
    Select and end it.

Contents
========

COLOR TUNER 2 Version 3.4 Release Notes
=======================================

Additions
---------

Support for New Things

66210

COLOR TUNER V3.4 additionally supports new devices.

RN_Heading

Coming soon

Support for Something New

66210

Note: COLOR TUNER V3.4 additionally supports more things.

RN_Heading

Length, width, height are unknown.

Modifications
-------------

Modification 1

12345

This is modification 1.

This is modification 1.

First modification

66211

COLOR TUNER V4.3 was modified.

Second modification

66212

Set the values as follows:

Value

Smoothing level

xxx

0

No smoothing

xxx

50 (default)

Medium

xxx

100

Maximum

xxx

This is all about the table.

Bug Fixes
---------

Bug Fix 1

12345

This is bug fix 1.

This is bug fix 1.

First Bug Fix

66211

COLOR TUNER V3.4 has been fixed.

Backmatter
==========

CGS ORIS GmbH

D-63512 Hainburg (Germany)

Phone: +49 6182 9626 0

Fax: +49 6182 9626 99

Web: http://www.cgs-oris.com

E-mail: support@xxxxxxxxxxxx

Current Thread