[xsl] template matching

Subject: [xsl] template matching
From: "james walker" <jameswalkerandy@xxxxxxxxxxx>
Date: Wed, 04 Feb 2004 13:26:30 +0000
if i have a note elemtn that can be placed in side many different elements within an xml document e.g.

<main>
<sub1><note></note><note></note><note></note></sub1>
<sub2></sub2>
<sub3><note></note></sub3>
<sub4><note></note><note></note><note></note><note></note></sub4>
<sub5></sub5>
</main>

If i wanted to produce a list of notes when the note element appears i would do something like this:

<xsl:template match="sub1">
<ul>
<xsl:apply-templates select="note" />
</ul>
</xsl:template>

<xsl:template match="sub3">
<ul>
<xsl:apply-templates select="note" />
</ul>
</xsl:template>

<xsl:template match="sub4">
<ul>
<xsl:apply-templates select="note" />
</ul>
</xsl:template>

<xsl:template match="note">
<li><xsl:value-of select="note" /></li>
</xsl:template>


Is there anyway i can reduce this code down because i have this implemented on a much larger scale where the note element appears within 28-30 other elements. Is there anyway to reproduce the output which the design above creates without having to write out <ul> tags within each template match?


cheers
james

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo


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



Current Thread