RE: [xsl] template matching

Subject: RE: [xsl] template matching
From: cknell@xxxxxxxxxx
Date: Wed, 04 Feb 2004 09:45:06 -0500
If your sample actually represents your input, you could create a template that matches a node based on a substring of the node's name.

<xsl:template match="*[substring(name(),1,3)='sub']">
<xsl:apply-templates select="note" />

Of course, if your element names have nothing in common that can be described with substring(), you will have to make one template for each.

Charles Knell
cknell@xxxxxxxxxx - email

-----Original Message-----
From:     james walker <jameswalkerandy@xxxxxxxxxxx>
Sent:     Wed, 04 Feb 2004 13:26:30 +0000
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  [xsl] template matching

if i have a note elemtn that can be placed in side many different elements 
within an xml document e.g.


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

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

<xsl:template match="sub3">

<xsl:template match="sub4">

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

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?


Express yourself with cool new emoticons

 XSL-List info and archive:

 XSL-List info and archive:

Current Thread