[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Page number ranges

Subject: Re: Page number ranges
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2002 12:09:16 +0000
word current pagenumber
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?



Jeni Tennison

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.