[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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"> <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@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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] empty element question, G. Ken Holman | Thread | RE: [xsl] empty element question, M C |
Re: [xsl] empty element question, G. Ken Holman | Date | RE: [xsl] empty element question, M C |
Month |
Keywords