Hi,
Just some comments on your xml.
It should be well-formed like this:
- xml declaration on the first line
- you must include 1 root element, eg. <p>
- you must include both start <br> and end </br> tags
- elements must be properly nested
- empty elements must be used like this: <br />
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="escaping.xsl"?>
<p>
<br>some text</br>
<br>some text</br>
<br>some text</br>
<br>some text</br>
<br><a>some link</a></br>
<br>some text</br>
<br>some text</br>
<br>some text</br>
<br>some text</br>
</p>
If I get it right, you want a result html, where a line break is inserted after each text node except before a link node?
The following xsl stylesheet uses xpath expressions to find the node containing a child named <a>.
It also uses <xsl:choose> to control where to place a line break.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head><title>Sample XSL Stylesheet</title></head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="br">
<xsl:choose>
<xsl:when test="child::*[1][self::a]"><xsl:value-of select="." /><xsl:text> </xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="." /><br /></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
HTH,