This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: XPath Query
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] XPath Query
- From: Bryan Tulloch <b dot tulloch at solicitec dot com>
- Date: Mon, 16 Jul 2001 10:19:38 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
Thanks, David. I do sometimes find myself creating complex templates when
something much simpler will suffice - am I alone in doing that?
-----Original Message-----
From: David Carlisle [mailto:davidc@nag.co.uk]
Sent: Monday, July 16, 2001 9:59 AM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] XPath Query
> I imagine that I need
> to call another template such as "third" below,
You're making it look much more complicated than it is:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
>
<xsl:output method="html" indent="yes"/>
<xsl:template match="DATA">
<table>
<xsl:apply-templates select="HISTORY"/>
</table>
</xsl:template>
<xsl:template match="HISTORY">
<tr>
<td><xsl:apply-templates select="DESCRIPTION"/></td>
<td><xsl:apply-templates
select="../NAME[@CODE=current()/NAME]/PERSON"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
produces
<table>
<tr>
<td>This is a history item 1</td>
<td>Fred Bloggs</td>
</tr>
<tr>
<td>This is a history item 2</td>
<td>John Smith</td>
</tr>
<tr>
<td>This is a history item 3</td>
<td>Fred Bloggs</td>
</tr>
<tr>
<td>This is a history item 4</td>
<td>Fred Jones</td>
</tr>
<tr>
<td>This is a history item 5</td>
<td>Fred Bloggs</td>
</tr>
</table>
on your input example. (which is what you asked for except that I
downcased the html elements: that future proofs the code for moving to
xhtml which is all lowercase.)
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list