[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL Transformation
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|