|
Subject: Re: [xsl] Request hints for creating TOC in HTML table From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 19 Jan 2004 17:35:22 -0500 |
I'll think something like this must have been done a thousand times before,
I have a xml document e.g. ... What I would like is to transform this document into a HTML table like with four columns
----------------------------- | # | E | J | Q | |365 BC| | | R | | A | F | K | S | |alpha | | L | T | | B | G | M | U | |bedroc| H | N | V | | C | I | O | X | | D | | P | Z | -----------------------------
Right know I can't either figure out how to sort the items in groups,
or find out how many groups to put into each column to make it look nice.
T:\ftemp>type thomas.xml
<content>
<item>bedrock</item>
<item>alphaville</item>
<item>Zebra</item>
<item>365 BC</item>
<item>alpha2</item>
<item>alphaz</item>
...
</content>T:\ftemp>type thomas.xsl <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY lower 'abcdefghijklmnopqrstuvwxyz0123456789'> <!ENTITY upper 'ABCDEFGHIJKLMNOPQRSTUVWXYZ##########'> <!ENTITY first 'translate(substring(.,1,1),"&lower;","&upper;")'> ]> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:i="internal" version="1.0">
<i:index> <l>#</l> <l>A</l> <l>B</l> <l>C</l> <l>D</l> <l>E</l> <l>F</l> <l>G</l> <l>H</l> <l>I</l> <l>J</l> <l>K</l> <l>L</l> <l>M</l> <l>N</l> <l>O</l> <l>P</l> <l>Q</l> <l>R</l> <l>S</l> <l>T</l> <l>U</l> <l>V</l> <l>W</l> <l>X</l> <l>Y</l> <l>Z</l> </i:index>
<xsl:template match="/">
<xsl:variable name="input" select="/"/>
<xsl:for-each select="document('')/*/i:index/l">
<xsl:value-of select="."/><xsl:text>
</xsl:text>
<xsl:variable name="index" select="."/>
<xsl:for-each select="$input">
<xsl:for-each select="key('firsts',$index)">
<xsl:sort/>
<xsl:value-of select="."/><xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template></xsl:stylesheet> T:\ftemp>saxon thomas.xml thomas.xsl # 365 BC A alpha2 alphaville alphaz B bedrock C D E F G H I J K L M N O P Q R S T U V W X Y Z Zebra
-- North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15 - (San Francisco, CA): 3-day XSLT/2-day XSL-FO 2004-03-22 Asia (Hong Kong, China): 3-day XSLT/2-day XSL-FO 2004-05-17 Europe (Bremen, Germany): 3-day XSLT/2-day XSL-FO 2004-05-24 Instructor-led on-site corporate, government & user group training for XSLT and XSL-FO world-wide: please contact us for the details
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Request hints for creating TO, Thomas V. Nielsen | Thread | [xsl] Testing if attribute node, Marcus Andersson |
| RE: [xsl] Accessing Global Paramete, Todd Baker | Date | Re: [xsl] Accessing Global Paramete, G. Ken Holman |
| Month |