Re: [xsl] URL parameters in xsl

Subject: Re: [xsl] URL parameters in xsl
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 22 May 2003 11:18:53 +0100
aside from any other problems, your code will always generate a (recoverable)
error if there is more than one chapter:

<div class="menu" ><xsl:for-each select="CHAPTER"> 
                        <xsl:attribute name="id"><xsl:value-of select="PARENTNAME"/>Menu</xsl:attribute> 
                        <div class="menuNode"><a ><xsl:attribute
                        name="href">default.asp?id=<xsl:value-of
 select="ID"/>%26parent=<xsl:value-of
                        select="PARENTNAME"/>%26size=<xsl:value-of
 select="SIZE"/>%26description=<xsl:value-of select="DESCRIPTION"/></xsl:attribute><xsl:value-of 
select="NAME" /></a> </div>
                        </xsl:for-each> </div></td>
                  </tr>
                </table>
                </xsl:for-each> </div>

For the first CHAPTER it will add an id attribute to the <div
class="menu" > element, then add a  <div class="menuNode"> child.

Then for the second CHAPTER it will attempt to (re) add the id attribute
to <div class="menu" > but this is an error as you can not add
attributes after  element nodes. I don't know what the code's trying to
do so can't suggest a fix.

Note however that as you are not generating the attribute names
dynamically you don't need all the <xsl:value-of and <xsl:attribute
complication.

<a ><xsl:attribute
                        name="href">default.asp?id=<xsl:value-of
 select="ID"/>%26parent=<xsl:value-of
                        select="PARENTNAME"/>%26size=<xsl:value-of
 select="SIZE"/>%26description=<xsl:value-of select="DESCRIPTION"/></xsl:attribute><xsl:value-of 
select="NAME" /></a>

is just a long way of writing

<a href=
"default.asp?id={ID}%26parent={PARENTNAME}%26size={SIZE}%26description={DESCRIPTION}">
  <xsl:value-of select="NAME" />
</a>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. 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


Current Thread