[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL Transformation

Subject: Re: XSL Transformation
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 15 Mar 2004 18:33:15 +0000
alphabet template
Hi Jim,

> I've trying to work on this XSL transformation but I am running into
> a wall. Can some help me get started?

OK. There are two steps to this:

1. A way of quickly going from a letter (e.g. 'C') to all the <row>
elements whose Keyword attribute starts with that letter.

2. A way of stepping through the alphabet one letter at a time, and
for each letter generating a <Keyword> element, with the appropriate
<Term> elements inside it (retrieved through the mechanism from step
1).

Step 1 can be achieved with a key. Write a key that indexes the <row>
elements by the first letter in their Keyword attribute. Keys are
created with <xsl:key>. You can get the first letter of a string with
the substring() function.

Step 2 needs a recursive template. You start off with the whole
alphabet and step through one letter at a time until there are no
letters left. The basic form of such a template is:

<xsl:template name="...">
  <xsl:param name="alphabet" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
  <xsl:if test="$alphabet">
    <xsl:variable name="letter" select="substring($alphabet, 1, 1)" />
    ...
    <xsl:call-template name="...">
      <xsl:with-param name="alphabet"
                      select="substring($alphabet, 2)" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

Within this template, you need to get the relevant <row> elements
using the key that you've created. You can do this with the key()
function.

Is that enough to get you started? If you have more questions, let us
know...

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.