Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] for-each-group and result-document splitting to less files. [Thread Next] Re: [xsl] for-each-group and result-document splitting to less files.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[,+(.><&&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
====================================================================== | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
