Given your input document, the following 2.0 stylesheet produces the
desired output:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="p">
<p>
<xsl:copy-of select="@*" />
<xsl:apply-templates select="span" />
</p>
</xsl:template>
<xsl:template match="span">
<xsl:variable name="attrs" select="@*" />
<xsl:for-each-group select="text() | *" group-starting-with="br">
<xsl:choose>
<xsl:when
test="not(normalize-space(string(string-join(current-group(),''))) =
'')">
<span>
<xsl:copy-of select="$attrs" />
<xsl:copy-of
select="normalize-space(string(string-join(current-group(),' ')))" />
</span>
<br/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="position() != last()">
<br/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
On Sun, Jun 6, 2010 at 9:12 PM, Israel Viente
<israel(_dot_)viente(_at_)gmail(_dot_)com> wrote:
Hi,
I have a problem splitting spans with text elements separated by br,
to different spans with br in between them.
Example Input:
<p dir="ltr"><span class="smaller">text1
<br />
text2
text3.
<br />
</span> <span class="smalleritalic">no</span> <span
class="smaller">problems.
<br />
<br />
</span></p>
Desired output:
<p dir="ltr"><span class="smaller">text1</span>
<br />
<span class="smaller">text2 text3.</span>
<br />
<span class="smalleritalic">no</span> <span
class="smaller">problems.</span>
<br />
<br />
</p>
Note: I need to create new span and preserve the span class when br
breaks inside a span.
Thanks for any idea.
Israel
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--