Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] for-each-group and result-document splitting to less files.

From: Wendell Piez <wapiez@---------------->
To:
Date: 9/8/2008 10:31:00 PM
James,



If this were my code, I'd be sorely tempted to encapsulate the logic 
in a function, if only to make it more legible and maintainable. This 
would also provide you a nice neat place to document it and its rationale.



Something like:



<xsl:function name="t:lettergroup" as="xs:string()">
  <xsl:param name="element" as="element()"/>
  <xsl:value-of select="translate(
    substring(normalize-space(lower-case($element)),1,1),
    'abcdefghijklmnopqrstuvwxyz012345678[,+(.&gt;&lt;&amp;&amp;amp;',
    'aaaaaaggggggmmmmmmssssssss999999999---------') "/>
  <!-- emits 'a','g','s','9' or '-' depending on the first
       letter of the value of $element, grouped into a-f, g-l, m-r,
       s-z, 0-9, or a punctuation mark (case insensitive) -->
</xsl:function>

Then



<xsl:for-each-group select="$persNamesWithoutKey"
                    group-by="t:lettergroup(.)">...

BTW, why the double-escaping of '&amp;amp;'? I can't see how that 
would do anything for you. The processor will see only the string '& 
a m p ;' here, which translate() will decompose into characters.



Cheers,
Wendell

At 08:02 AM 9/8/2008, you wrote:
On Fri, Sep 5, 2008 at 14:19, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>> I want to break it into 5 files for punctuation&numbers, a-f,
>> g-l, m-r, and s-z.
>
> Part of the solution might be to use a grouping key created using
>
> translate(., 'abcdefghijklmnopqrstuvwxyz', 'aaaaaaggggggmmmmmmssssssss')
>

Having had a chance to play with this on the outer xsl:for-each-group I did:



 <xsl:for-each-group select="$persNamesWithoutKey"
group-by="translate(substring(normalize-space(lower-case(.)),1,1),'abcdefghijklmnopqrstuvwxyz012345678[,+(.&gt;&lt;&amp;&amp;amp;
', 'aaaaaaggggggmmmmmmssssssss999999999---------') ">

and with some minor cosmetic changes through the rest that did it
absolutely perfectly for my needs.

I post this just for posterity (i.e. anyone else searching for a
similar answer and in several months when I've forgotten how/why I did
something like this!)   ;-)

Many thanks,



-James




======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
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
======================================================================


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent