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
- Subject: Re: [xsl] XPath Query
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Mon, 16 Jul 2001 09:59:22 +0100
- References: <8A7515596578D511BCDD00B0D0D0F46A0CFDE2@EXCHANGE>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> 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