In XSLT 2.0, using positional grouping:
<xsl:for-each-group select="node()" group-starting-with="lb">
<p>
<xsl:copy-of select="current-group()[not(self::lb)]"/>
</p>
</xsl:for-each-group>
This is sufficiently general to handle more complex instances than you show:
multiple <lb/> elements, other markup as children of <p>, etc. It doesn't
handle the more complex problem of an <lb/> element that's a descendant of
the <p> element rather than a child - that one comes up on this list
occasionally, and is hard.
Regards,
Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay
-----Original Message-----
From: M C [mailto:mcundiff11(_at_)yahoo(_dot_)com]
Sent: 16 October 2009 21:05
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] empty element question
How do I transform this input document:
<div>
<p>string 1<lb/>string 2</p>
</div>
to this output document?
<div>
<p>string 1</p>
<p>string 2</p>
</div>
Thanks,
Morgan
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--