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

Subject: Re: Group by optimism
From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Feb 2026 22:58:07 -0000
On Fri, 13 Feb 2026 17:27:54 -0000
"rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> I have it working, but curious if there is a way to optimize the code
> or make it more readable. Thanks in advance.

Minor: no need to use /. after a name test, it's the same without it.
And child is the default axis, that's already bee mentioned.

Second, your two cases in your xsl:choose are almost the same. You
could use if then else inside the XPath expressions instead:

<xsl:variable name="have-key" as="xs:boolean"
select="current-grouping-key()" />

<title>{ if ($have-key) then current-grouping-key() else
"Symbols" }</title>

and

<xsl:for-each-group
select="current-group()"
group-by="if ($have-symbols)
          then upper-case(substring(normalize-space(caseName), 1, 1))
          else caseName"

caseName">

the idea being to repeat as little as possible, in general.

But what you have is not wrong or bad.

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