xsl-list
[Top] [All Lists]

RE: [xsl] empty element question

2009-10-16 16:32:09
Thank you Michael and Ken for pointing out that this is a grouping problem. 
Very clear. I know this is the wrong list but it makes wonder then how you do 
it with XQuery...

Thanks,
Morgan

--- On Fri, 10/16/09, Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:

From: Michael Kay <mike(_at_)saxonica(_dot_)com>
Subject: RE: [xsl] empty element question
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Friday, October 16, 2009, 8:15 PM

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>
--~--




      


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>