[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Dividing a list of nodes into parts of the alphabet


Subject: [xsl] Dividing a list of nodes into parts of the alphabet
From: Jannis Pohlmann <info@xxxxxxxxxxx>
Date: Fri, 03 Dec 2004 05:35:55 +0100

Hello,

I am working on a shop system for a friend of mine. This system shall parse
one XML file into several static XHTML documents.
As you may expect, there are several problems to manage. XHTML documents
have to be created for each product, for each category and so on.
Creating a page for each product in its categories
directory - e.g. /catalogue/CDs/product_120.html - is easy using
xsl:result-document since I make use of the latest version of Saxon
and XSLT 2.0.

But with the categories I ran into several logistic yet highly
interesting problems:

To explain this I will have describe some parts of my XML structure:

---

<categories>
   <group name="CDs">
      <cat id="cd">CD</cat>
      <cat id="mcd">MCD</cat>
      <cat id="digicd">Digipack CD</cat>
   </group>
   <group name="LPs">
      <cat id="lp">LP</cat>
      <cat id="ep">EP</cat>
      <cat id="10">10 inch</cat>
   </group>
   <group name="Textiles">
      <cat id="tshirt">T-Shirt</cat>
      <cat id="ls">Longsleeve</cat>
   </group>
</categories>

(...)

<item>
   <artist>Satyricon</artist>
   <title>Rebel Extravaganza</title>
   (...)
</item>
<item>
   <artist>Secrets of the Moon</artist>
   <title>Carved in Stigmata Wounds</title>
</item>

---

As you may imagine, the shop might have lots more
CDs than, for example, Textiles, so I would like to add an
opportunity to split the page created for each
<group> into one or more pages, each including all artists beginning
with the same letter or one letter out of a range of letters.

---

First example:
   (catalogue/CDs/CDs.html -> mapped to A.html by Apache's mod_rewrite)
   catalogue/CDs/A.html
   catalogue/CDs/B.html
   (...)
   catalogue/CDs/Z.html
   (and catalogue/CDs/0-9.html of course but that should be no
   problem with  <xsl:sequence select="0 to 9"> or somewhat)

Second example:
(catalogue/LPs/LPs.html -> redirected to A-E.html by Apache's mod_rewrite)
catalogue/LPs/A-E.html
catalogue/LPs/F-J.html
(...)
catalogue/LPs/U-Z.html


Third example
   catalogue/Textiles/Textiles.html

---

I think this is kind of tricky as I want to make the splitting option
as variable as possibly.
What I don't know is if I need a new attribute or child in <group/> with
comma-separated letters/letter-groups and how I may interpret these. Or
is it possible to interpret letters or letter-groups as xsl:sequence's
in order to iterate through them?

I have been thinking about this for two hours now. Perhaps some of
you do know a solution for it or at least are able to help in developing
one.

Greetings,
Jannis


Current Thread
Keywords