[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|