[Home] [By Thread] [By Date] [Recent Entries]

Subject: Re: Optimising XSLT 2.0 restructuring of large SVRL files (Saxon-HE 12.9)
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 May 2026 18:47:49 -0000
On Tue, 26 May 2026 12:32:30 -0000
"Susanne Wunsch susanne.wunsch@xxxxxxxxxxxxx"
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> a) keep all the grouping logic encapsulated within a single template
> (i.e. nested xsl:for-each-group plus inline xsl:element
> constructions), or
>
> b) spread the logic across several templates, dispatched via match
> and mode (so each "level" of the hierarchy has its own mode and its
> own dedicated templates)

(b) for several reasons - but with a caveat, see below...

* individual templates are easier to fix if there's problems, and to
test;

* XSLT streaming tends to enforce this style because of restrictions on
  what a template can do

* you can override a template e.g. in a separate stylesheet, to change
  just part of the behaviour (but donbt go overboard with this!)

The caveat:

Make sure your modes have clear names describing their purpose, and
that all the templates for a given mode are next to each other. In XSLT
4 (working draft) you can put the templates inside the xsl:mode element
that declares them.

A stylehseet with modes mode1, mode2, ... mode26, that all do different
unrelated things is a nightmare to work on.

Note, in XSLT 3 you can add on-no-match="shallow-copy" to xsl:mode and
not need the identity template.

Also, node() matches comment nodes, so i think you don't need
comment()|node(), although if it's there as a reminder that's fine.

I would add more comments, e.g.
<!--* move all comments to the start of the element,
    * then process the child elements, before handling the
    * active patterns
    *-->
so that someone looking at it (maybe you next year) can see where there
is a difference between the intent and the actual action :)

But as it stands itbs reasonably short and clear.

liam



--
Liam Quin: Delightful Computing - Training and Consultancy in
XSLT / XML Markup / Typography / CSS / Accessibility / and more...
Outreach for the GNU Image Manipulation Program
Vintage art digital files - fromoldbooks.org

Current Thread
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member