I have text in a node, that contains html-like carriage-return <br/>
. I want to keep this empty nodes within an XSLT conversion, but I do not succeed.
Here is an example XML-input:
<?xml version="1.0"?>
<eventlist>
<event>
<summary>Meeting Harry</summary>
<description>Talk for Mistex Project<br/>Invite Spec</description>
</event>
<event>
<summary>Shopping with Lance</summary>
<description>Need Christmas Gift<br/>Joint Lunch<br/>Check for car</description>
</event>
</eventlist>
Please note the <br/>
's between the <description>
-nodes. While transforming to html, I want to keep the <br/>
's, the result should be something like
<?xml version="1.0" encoding="iso-8859-1"?>
<table>
<tbody>
<tr>
<td>Meeting Harry</td>
<td>Talk for Mistex Project<br/>Invite Spec</td>
</tr>
<tr>
<td>Shopping with Lance</td>
<td>Need Christmas Gift<br/>Joint Lunch<br/>Check for car</td>
</tr>
</tbody>
</table>
But using the following very simple XSLT
<!-- ******************************** -->
<xsl:template match="/">
<table>
<tbody>
<xsl:apply-templates select="eventlist/event"/>
</tbody>
</table>
</xsl:template>
<!-- ******************************** -->
<xsl:template match="event">
<tr>
<td>
<xsl:value-of select="summary"/>
</td>
<td>
<xsl:apply-templates select="description"/>
</td>
</tr>
</xsl:template>
<!-- ******************************** -->
<xsl:template match="description">
<xsl:value-of select="."/>
<xsl:apply-templates select="br"/>
</xsl:template>
<!-- ******************************** -->
<xsl:template match="br">
<br/>
</xsl:template>
<!-- ******************************** -->
</xsl:stylesheet>
I get something weird like
<?xml version="1.0" encoding="iso-8859-1"?>
<table>
<tbody>
<tr>
<td>Meeting Harry</td>
<td>Talk for Mistex ProjectInvite Spec<br/>
</td>
</tr>
<tr>
<td>Shopping with Lance</td>
<td>Need Christmas GiftJoint LunchCheck for car<br/>
<br/>
</td>
</tr>
</tbody>
</table>
The carriage returns are misplaced at the end of the description. The <xsl:value-of select="."/>
just ommits the intermediate nodes, what is expectable. I just don't have solution for that, maybe there is a complete easy one? I don't get the <br/>
on the right place. What am I doing wrong???