[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

for-each-group grouping accented versions of letters

Subject: for-each-group grouping accented versions of letters together
From: Graydon <graydon@xxxxxxxxx>
Date: Fri, 20 Apr 2012 20:03:55 -0400
 for-each-group grouping accented versions of letters
So I've got an XML index file, which is too large for some downstream
processing to be entirely pleased with.  The requirement is to split the
file up, grouping index entries (index-0 elements; the index element is
the overall container element) by the first character of their child
heading element.

Using XSLT 2.0, this is pretty easy:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="xs xd" version="2.0"
  xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/wkna-shared-cms/index">
    <xsl:for-each-group group-by="substring(heading,1,1)" select="index-0">
      <xsl:sort select="./heading"/>
      <xsl:result-document href="eitaindex+Topical_Index_{current-grouping-key()}.xml">
        <wkna-shared-cms>
          <index area="{/wkna-shared-cms/index/@area}"
            xml:lang="{/wkna-shared-cms/index/@xml:lang}">
            <num cite="Topical Index {current-grouping-key()}">
              <xsl:sequence select="current-grouping-key()"/>
            </num>
            <xsl:copy-of select="/wkna-shared-cms/index/index-metadata"/>
            <xsl:copy-of select="current-group()"/>
          </index>
        </wkna-shared-cms>
      </xsl:result-document>
    </xsl:for-each-group>
  </xsl:template>
</xsl:stylesheet>

The problem is that some of the initial characters of the headings have
accents, and it's desired that the accented characters and the
unaccented characters group together, so that E and I and J, etc. all
group together in a group with a current-grouping-key() of "E".

I can imagine doing this in a painful way with conditional statements
and an exhaustive list of characters, but I'm hoping someone can tell me
there's a better way.

Thanks!

-- Graydon

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.