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

Re: template matching

Subject: Re: template matching
From: "james walker" <jameswalkerandy@xxxxxxxxxxx>
Date: Fri, 06 Feb 2004 16:17:00 +0000
template matching
Yeah its working fine :)
thanks very much for the explanation now, still learning some basic things/shortcuts which i didnt know before! (e.g. dont have to write select="*")
thanks again
james



From: David Carlisle <davidc@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  template matching
Date: Fri, 6 Feb 2004 16:00:51 GMT

> 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


_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband



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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.