Re: [xsl] transforming XSLT files to use XSLT3 features

Subject: Re: [xsl] transforming XSLT files to use XSLT3 features
From: "Joel Kalvesmaki director@xxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 11 Feb 2023 17:23:48 -0000
Because XSLT files are themselves XML files, I've been intrigued by
the idea of using XSLT to improve its own stylesheets.

Two other comparable use-cases worth mentioning:


1. M Ricaud's XSLT-quality: https://github.com/mricaud/xslt-quality.

Front-facing is the Schematron schema that can be used to find flaws in one's XSLT. Under the hood, the hard work is being done by an XSLT stylesheet that parses the contents. Pretty innovative use of XSLT to improve XSLT.

2. Self-refactoring. (I have working examples, but they're not yet presentable.)

An XSLT may have components that need to be updated. For example, an XSLT global variable might defining a mapping to or from Unicode characters, and it may need to be updated with a new release of Unicode.

My steps:

- Define a global *static* parameter with a boolean, e.g., $update-me.
- Use $update-me to distinguish the default template path between regular use and an update, by means of XSLT's @use-when.
- The update default template mode, e.g., mode="self-update", is @on-no-match="shallow-copy".
- One or more templates in the self-update mode select the desired components and update them as needed.


The stylesheet would be used in its regular fashion. But when it needs to be updated, it would be passed as input into itself with $update-me=true and voila, out comes the updated stylesheet.

Lots of creative variants for self-refactoring.

Best wishes,

jk
--
Joel Kalvesmaki
Director, Text Alignment Network
http://textalign.net

Current Thread