This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: strangeness with <xsl:variable>


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]