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

RE: template matching

Subject: RE: template matching
From: cknell@xxxxxxxxxx
Date: Wed, 04 Feb 2004 09:45:06 -0500
template matching
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']">
<ul>
<xsl:apply-templates select="note" />
</ul>
</xsl:template>

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:   template matching

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

<xsl:template match="sub4">
</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




 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.