Try
<xsl:template match="para">
<xsl:for-each-group group-adjacent="self::image or self::table">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:copy-of select="current-group()"/>
</xsl:when>
<xsl:otherwise>
<p><xsl:copy-of select="current-group()"/></p>
</xsl:otherwise>
</
</
</
What this is doing is to form a series of alternating sequences consisting
of a sequence of consecutive images/tables, followed by a sequence of
consecutive non-tables-and-images; and you're then wrapping the sequence of
non-tables-and-images in a <p> element.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Tristan Stevens [mailto:tristanstevens(_at_)hotmail(_dot_)com]
Sent: 11 November 2006 00:01
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Un-nesting elements in XSLT 2.0
Hi,
I've got a problem that I've been pondering over and I'm sure
there's a pattern for doing this.
I have a hierarchical structure that I need to break out, but
things seem to get confusing when mixed content models come into play.
Example:
<para>
This is some above image text<sup>See footnote 1</sup>
<image src="image1.gif" alternative="My Image"/>
This is some text in between the image and table.
<table>
<tr>
<td>...
...
</table>
Some more text to finish the paragraph off.
</para>
I need to convert this into the following:
<p>This is some above image text <sup>See footnote
1</sup></p> <img src="image1.gif alt="My Image"/> <p>This is
some text in between the image and table.</p> <table>
...
</table>
<p>Some more text to finish the paragraph off.</p>
The way that you'd want to write your XSL would be something like:
<xsl:template match="para">
<p>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="image">
</p>
<img>
<xsl:attribute...
...
</img>
<p>
</xsl:template>
but of course that is non-sensical.
What is the easiest and/or most efficient way to do this in XSLT 2.0?
Thanks
Tristan
**********************************************
Tristan Stevens
--~------------------------------------------------------------------
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>
--~--