RE: [xsl] strangeness with <xsl:variable>

Subject: RE: [xsl] strangeness with <xsl:variable>
From: "Devlin, Kurt" <Kurt.Devlin@xxxxxxxxxxxxx>
Date: Wed, 20 Dec 2000 14:52:50 -0600
> ...I have to put in <a name="something"> for
> every part, chapter, and section marked in the XML.  And
> then, when I generate the TOC, I need to put in <a
> href="#something"> so the user can clink on it to take them
> to the desired content.

You could try using generate-id() for your name and href attributes.

> 1. When doing this:
> <xslvariable name="name">
>     chap<xsl:number count="chapter"/>
> </xsl:variable>
> 
> <a name="{$name}">
>   [....]
> I get control characters in the HTML, a la:
>   <a name="%A0%20chap1">

You need to put your text inside of a <xsl:text> block. Like the following:

<xslvariable name="name">
    <xsl:text>chap</xsl:text><xsl:number count="chapter"/>
</xsl:variable>

> The XML source has appendices, and an introduction as well
> as chapters, and the numbering of the sections within them
> need to be different . . . i.e. in the intro it should look
> like "sect-intro-1", in an appendix as "sect-IV.A.1".  I
> thought the natural way to do this is to use a
> <xsl:variable> within a <xsl:choose>.  So I did this . . .

You got this backwards... You need to put the choose inside of the variable.
In your example, the variable loses scope as soon as the choose block is
finished.

I hope that helps.

Regards,
Kurt

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


Current Thread