xsl-list
[Top] [All Lists]

Re: alphabetic set of xsl:result-document

2005-08-22 08:12:47

are you saying I should do something along the (currently-broken)

sir, surely you are not suggesting that I would suggest a broken
approach? It will have to be pistols at dawn...

. selects exctly one thing and lower-case() doesn't change that so this
line isn't doing very much: you are sorting/grouping a sequence of length 1.
<xsl:for-each-group select="lower-case(.)"

You have the groups inside out: you first want (I think) to group on initial
letter, then, within that, group on the words.



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0">
 
<xsl:template match="/">
<xsl:for-each-group select="//w" group-by="lower-case(substring(.,1,1))">
<xsl:result-document href="FILE-{current-grouping-key()}.html">
<html>
<body>
<h1>words beginning with <xsl:value-of 
select="lower-case(substring(.,1,1))"/></h1>
<xsl:for-each-group select="current-group()" group-by="lower-case(.)">
<p><xsl:value-of select="."/> (<xsl:value-of 
select="concat(count(current-group()),' time',
    if (current-group()[2]) then 's' else '')"/>) </p>
</xsl:for-each-group>
</body>
</html>
</xsl:result-document>
</xsl:for-each-group>
</xsl:template>



 </xsl:stylesheet>



saxon8 w.xml w.xsl

$ more FILE-*
::::::::::::::
FILE-a.html
::::::::::::::
<html>
   <body>
      <h1>words beginning with a</h1>
      <p>a (10 times) </p>
   </body>
</html>
::::::::::::::
FILE-b.html
::::::::::::::
<html>
   <body>
      <h1>words beginning with b</h1>
      <p>boring (1 time) </p>
   </body>
</html>
::::::::::::::
FILE-i.html
::::::::::::::
<html>
   <body>
      <h1>words beginning with i</h1>
      <p>is (5 times) </p>
   </body>
</html>
::::::::::::::
FILE-o.html
::::::::::::::
<html>
   <body>
      <h1>words beginning with o</h1>
      <p>only (5 times) </p>
   </body>
</html>
::::::::::::::
FILE-s.html
::::::::::::::
<html>
   <body>
      <h1>words beginning with s</h1>
      <p>simplified (1 time) </p>
   </body>
</html>
::::::::::::::
FILE-t.html
::::::::::::::
<html>
   <body>
      <h1>words beginning with t</h1>
      <p>This (5 times) </p>
      <p>test (10 times) </p>
   </body>
</html>


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>