This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: strangeness with <xsl:variable>
- To: Mike Hostetler <mikeh at nukeroad dot net>
- Subject: Re: [xsl] strangeness with <xsl:variable>
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Sat, 23 Dec 2000 20:31:46 +0000
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <20001220203900.20972.qmail@web110.yahoomail.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Mike,
Just a couple of comments:
> 1.) use <xsl:text>sect-</xsl:text><xsl:number/>, which I haven't
> done throughout the whole transform. It's a wonder that this didn't
> bit me before.
You may find it helpful to use Allouche's method for getting rid of
whitespace here, i.e. use an empty xsl:text element to indicate the
end of ignorable whitespace:
<xsl:text />sect-<xsl:number />
It's a little shorter, and a little more readable. You don't have to
use xsl:text at all if there's no whitespace, of course:
<xsl:when
test="parent::introduction"><xsl:text>sect-intro</xsl:text><xsl:number
format="1" level="single" count="section"/></xsl:when>
will produce exactly the same as:
<xsl:when test="parent::introduction">sect-intro<xsl:number
format="1" level="single" count="section"/></xsl:when>
The alternatives:
<xsl:when test="parent::introduction">
<xsl:text />sect-intro<xsl:number format="1" level="single"
count="section"/>
</xsl:when>
and:
<xsl:when test="parent::introduction">
<xsl:text>sect-intro</xsl:text>
<xsl:number format="1" level="single" count="section" />
</xsl:when>
just give nicer formatting within the stylesheet (especially if you
have a fixed line length).
> <xsl:number format="I.1.1" level="multiple" count="//part | chapter
> | section"/>
The 'count' attribute gives a match expression against which the
ancestors and their preceding siblings are matched to create the
numbering scheme. In your 'count' attribute, the first term is
'//part', which matches any 'part' element that is a descendant of the
root node. This will match any 'part' elements that it comes across,
as will, simply 'part'. There is never any point in having '//' at the
beginning of a match pattern: the only constraint it adds is that the
node is a descendant of the root node, which is true for all nodes -
it's therefore no constraint at all, and completely superfluous.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list