Transforming XHTML data problem

admin

Administrator
Staff member
I have XHTML data that I wish to transform into a comma-delimited file using XSLT.

A sample of the input data is as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href=http://www.webdeveloper.com/forum/archive/index.php/"test.xsl"?>
<html>
<body>
<table>
<tr>
<td>1 AACS<br />1st Airborne Air Control Squadron</td>
<td>website: <!-- w --><a class="postlink" href="http://www.1AACS.mil">www.1AACS.mil</a><!-- w --></td>
</tr>
<tr>
<td>128 AACS<br />128th Airborne Air Control Squadron</td>
<td>website: <!-- w --><a class="postlink" href="http://www.128AACS.mil">www.128AACS.mil</a><!-- w --></td>
</tr>
</table>
</body>
</html>


My XSL file looks like this...

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>

<xsl:template match="/">

<xsl:for-each select="html/body/table/tr">

<xsl:for-each select="td">
<xsl:value-of select="."/>,
</xsl:for-each>

<xsl:text><!-- line break -->
</xsl:text>

</xsl:for-each>

</xsl:template>
</xsl:stylesheet>
The problem is the data in the first cell of each table row has a <br/> tag in it which isn't used in the transformed output.

For example the first row looks like this in the transformed output:
1 AACS1st Airborne Air Control Squadron, website: <!-- w --><a class="postlink" href="http://www.1AACS.mil">www.1AACS.mil</a><!-- w -->

The "1 AACS" and "1st Airborne ..." bump against one another.

I'm wondering is there a way to translate that <br/> tag, or parse the data before and after it so I can get the output to look something like this:
1 AACS, 1st Airborne Air Control Squadron, website: <!-- w --><a class="postlink" href="http://www.1AACS.mil">www.1AACS.mil</a><!-- w -->

Thanks for your help.
 
Back
Top