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]
Other format: [Raw text]

Re: Page number ranges


Hi Gustaf,

> Thank you for your help Jeni. It gave some ideas on the logics
> involved, but as I embed this code into my stylesheet there are no
> page numbers at all in the output. Perhaps there is something in
> what I have written that conflicts with the code you suggested, so I
> post the whole template here to see if you or someone else can spot
> the problem.
>
>   <xsl:template match="word">
>     <!-- I put your variable here in the top. -->
>     <xsl:variable name="entries" select="word[. = current()]" />

The variable is currently selecting all the word elements that are
children of the current word element and whose value is the same as
the current word element. I don't think that you have word elements
nested inside other word elements, so this will return an empty set
all the time, which is why you're having problems with it.

Try using the following instead:

  <xsl:variable name="entries" select="../word[. = current()]" />

Or of course you could create a key that indexes all the word elements
in the document by their value:

<xsl:key name="words" match="word" use="." />

and then use:

  <xsl:variable name="entries" select="key('words', .)" />

By the way, collecting the words together for this variable is quite
time-consuming, so since you're applying templates to *all* the words,
but only actually processing some of them (within the xsl:if), I'd
move the xsl:variable within the xsl:if (or just before the
xsl:for-each) instead of having it at the top of the template.

> "12-13" is good, but I wonder what happens if there are matches on
> page 12, 13, 14 and 15? Will they be written "12-14, 15" or "12-15"?

12-15. I assume that's what you wanted?

Cheers,

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]