How can XSL transform XHTML data into fragments?
Hi,
I wonder if anyone know how use XSL to transform an XHTML file that contains certain blocks of text within the <td> tags, for example:
<td valign="TOP" align="LEFT" bgcolor="#FFFFFF" width="260" class="WhiteBackBlackText">Is London the best place?</td>
where I try to extract "Is London the best place?" to a data section named "<tag>", so that the result will be:
<tag>Is London the best place?</tag>
I know you can do certain apply-templates functions, but just do not know how I can get the data from an XHTML extract such as a piece of table data within a table.
The following code will get me back all the text of all the table data fragments that exists to put into the <tag></tag> section.
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<root>
<xsl:apply-templates select="table/tr"/>
</root>
</xsl:template>
<xsl:template match="td">
<tag><xsl:value-of select="." /></tag>
</xsl:template>
</xsl:stylesheet>
Am I on the right lines?
I will be very grateful for any suggestions :)!!
|