[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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:
Then
BTW, why the double-escaping of '&'? 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.
At 08:02 AM 9/8/2008, you wrote:
Re: [xsl] for-each-group and result-document splitting to less files.
Subject: Re: [xsl] for-each-group and result-document splitting to less files. From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Mon, 08 Sep 2008 18:25:20 -0400 |
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[,+(.><&&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;'? 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[,+(.><&&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 ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] for-each-group and result, James Cummings | Thread | Re: [xsl] for-each-group and result, James Cummings |
Re: [xsl] xsl: parsing through spec, Mohit Anchlia | Date | [xsl] xslt function, Mohit Anchlia |
Month |
Keywords