xsl-list
[Top] [All Lists]

Re: template matching

2004-02-06 09:00:51

Please could u explain to me how it works in more detail?
Just this once (since I'm not sure the list's auto-documentation daemon is
actually fully back in working order, although she has been spotted
recently)


Whats steps would be involved in order to create the note list? (not really 
sure why 3 template matches are needed for it?)

The code I posted (plus your template for scope, made well formed:-)
does the trick doesn't it? 

explaining how it works:


<xsl:template match="scope">
<xsl:apply-templates select="*" />
</xsl:template>


or even just


<xsl:template match="scope">
<xsl:apply-templates/>
</xsl:template>

is going to process all children of scope, so

<xsl:template match="misc">
<p><xsl:value-of select="." /></p>
</xsl:template>

will do the usual thing and make a p element

we don't want most of the note elements to produce anything (as the
first note element in each bunch is going to generate the whole list) so
have a template that zaps them:

<xsl:template match="note"/>

Now we do want the first of each notes to do something so that's a note
who's immediately preceding element is not a note

<xsl:template match="note[not(preceding-sibling::*[1][self::note])]">

this has higher priority thatn the simple  match="note" so when both
match this template (not the other one) will fire.

Thus template has to make a list and then make the items in it
the items will be made in "note" mode so just apply-templates back to
this node in note mode:

<ul>
<xsl:apply-templates mode="note" select="."/>
</ul>
</xsl:template>


in note mode you should only ever see a note element what you have to do
is make a list item, and then process your following sibling if it is a
note and stop otherwise:

<xsl:template match="note" mode="note">
<li><xsl:apply-templates/></li>
<xsl:apply-templates select="following-sibling::*[1][self::note]" mode="note"/>
</xsl:template>

(you had <lli) there shoudl be ,li) of course.

David

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
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
________________________________________________________________________

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



<Prev in Thread] Current Thread [Next in Thread>