xsl-list
[Top] [All Lists]

Re: [xsl] Can group-by treat its target it two ways?

2011-11-08 10:00:55
Hi Mark,

On 11/7/2011 8:14 PM, Mark wrote:
if contains($seq,lower-case(substring(@word,1,1)))

Interesting,
My "group-by" was used to name the files that each current-group()
produced, one for each letter of the Czech alphabet. My very verbose
expression did this using the current-grouping-key(). Would your code
produce one file each for the four diacritical letters in $seq? or put
them all in one file?

Andrew and I are refactoring only the conditional test in your group-by expression (or parts of it), without reference to what happens inside the grouping. So (if done right) these modifications should work just like your present code.

Also, don't forget the digraph 'ch', the ninth letter of the Czech
alphabet - can you find a succinct way to insert it in your more terse
expressions?

If the two-character sequence "ch" represents the digraph -- as implied by your original code, although IANAC (I am not a Czech) -- the regex I suggested yesterday does that:

if matches(lower-case(@word),'^([čřšž]|ch)')
   then replace(lower-case(@word),'^([čřšž]|ch).*$','$1')
   else lower-case(substring(cps:remove-diacritics(@word), 1, 1))

The use of the = operator to reduce the set of "or" clauses (as Andrew suggested) and the "contains()" trick would handle only the single-letter cases. You'd still have to handle the "ch" case on its own:

group-by="if contains($seq,lower-case(substring(@word,1,1))) then
  lower-case(substring(@word,1,1)) else
  if (lower-case(substring(@word,1,2)) eq 'ch') then 'ch' else
  lower-case(substring(cps:remove-diacritics(@word), 1, 1))"

Cheers,
Wendell

======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--