Subject: Re: XPath Query
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 16 Jul 2001 09:59:22 +0100
|
> 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
| Current Thread |
- XPath Query
- Bryan Tulloch - Mon, 16 Jul 2001 04:46:08 -0400 (EDT)
- David Carlisle - Mon, 16 Jul 2001 05:04:43 -0400 (EDT) <=
|
|