Re: [xsl] Linenumbering & word index

Subject: Re: [xsl] Linenumbering & word index
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 6 Aug 2004 17:56:43 +0100
> > [
> > <xsl:copy-of  select="$x"/>
> > ]
> 
> Copy of the temporary tree listing each poem, and word in line 
> for that poem.

debugging output only that of course, you need $x you don't need to copy
it to the output.



> then for each instance of a word (keys always confuse me) it 
> outputs the @poem and @n line numbers.

replace the key('w',.) by //word[.=current()] if you prefer (you can
_always_ do that, it's the same thing, just quicker (can be a _lot_
quicker on large docs)

actually i suspect that i slipped back into xslt1 there, I was using
the key to get all the other instances of this word, but
xsl-for-each-group has already done that, so you should use
current-group() there which should be the same thing. (which means you
can get rid of xsl;key)


> Applies the original mode a match for divs only 
> to head and lg/l (modes...yes, must use modes more.)
> > <xsl:template mode="a" match="div">
> > <div poem="{position()}">
> > <xsl:apply-templates mode="a" select="head"/>
> > <xsl:apply-templates mode="a" select="lg/l"/>
> > </div>
> > </xsl:template>
> > 

yes not position() here is the right thing because we selected (only)
the divs we wanted in the top level select. If you selecteed everything
and then had templates that junked teh things you didn't need, position
would be the wrong thing and you'd have to use xsl:number or some such

> When you find a l tokenize it into a temporary tree 
> of <word> elements, recording the line's position

yes but you should include punctuation in the tokenization, and
lowercase, ie copy the code from the head template, they should be more
or less the same.

> Seems to work absolutely perfectly.
happens, sometimes.

David



________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread