xsl-list
[Top] [All Lists]

Re: [xsl] Grouping by letters but keep symbols together

2019-01-25 08:52:43
On 25.01.2019 15:44, Rick Quatro rick(_at_)rickquatro(_dot_)com wrote:

I am creating a glossary and I want to group entries under each letter of the alphabet. I am using this and it is working fine:

<xsl:for-each-group select="glossentry" group-by="upper-case(substring(glossterm/text(),1,1))">

     <topicref navtitle="{current-grouping-key()}" toc="no">

...

     </topicref>

</xsl:for-each-group>

However, I want to group entries that start with a symbol or number all together under one group. I am not sure what to use for the group-by attribute so that letters are separate from each other and all of the non-letter characters are in the same group.

Along the idea of Michele's answer, but using XPath 2 and "replace" instead of "translate"

  group-by="replace(upper-case(substring(glossterm, 1, 1)), '\P{L}', '#')
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>