RE: [xsl] empty element question

Subject: RE: [xsl] empty element question
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 16 Oct 2009 21:15:36 +0100
In XSLT 2.0, using positional grouping:

<xsl:for-each-group select="node()" group-starting-with="lb">
    <xsl:copy-of select="current-group()[not(self::lb)]"/>

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.


Michael Kay  

> -----Original Message-----
> From: M C [mailto:mcundiff11@xxxxxxxxx] 
> Sent: 16 October 2009 21:05
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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

Current Thread