xsl-list
[Top] [All Lists]

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

2019-01-25 09:32:45
Beyond all these suggestions, I always create functions that return grouping 
and sort  keys as the logic could be much more sophisticated, especially if you 
bring in locale-aware processing.

Cheers,

E.
--
Eliot Kimber
http://contrext.com
 

On 1/25/19, 9:07 AM, "Graydon graydon(_at_)marost(_dot_)ca" 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

    On Fri, Jan 25, 2019 at 02:44:50PM -0000, Rick Quatro 
rick(_at_)rickquatro(_dot_)com scripsit:
    >    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:
    [snip]
    >    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. Any suggestions would be
    >    appreciated. Thank you very much.
    
    I'd use a Unicode character category match for this:
    
    <xsl:for-each-group select="glossentry"
       
group-by="(substring(upper-case(glossterm),1,1)[matches(.,'\p{Lu}')],'NON-LETTER-GROUP')[1]">
        <topicref navtitle="{current-grouping-key()}" toc="no">
            ...
        </topicref>
    </xsl:for-each-group>
    
    What you put in for "NON-LETTER-GROUP" might depend on where or how
    you're sorting the glossary entries.
    
    -- Graydon
    
    
    
--~----------------------------------------------------------------
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>