2009/2/7 Myles Pflum <myles_pflum(_at_)filemaker(_dot_)com>:
First time poster in need of assistance =)
Using XSLT 1.0, given the following structure:
<document>
<aaa />
<aaa />
<aaa />
<aaa />
<aaa stylename='start' />
<aaa />
<aaa />
<aaa />
<aaa />
<aaa stylename='finish' />
<aaa />
<aaa />
<aaa />
<aaa />
<aaa />
<aaa stylename='start' />
<aaa />
<aaa />
<aaa stylename='finish' />
<aaa />
<aaa />
</document>
How can I make the <aaa /> elements that exist in between @='start' and
@='finish become children of <aaa stylename='start' />?
I'm afraid it's bit of a challenge with xslt 1.0:
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()[1]"/>
</xsl:copy>
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
<xsl:template match="aaa[(_at_)stylename = 'start']">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:copy-of select="following-sibling::aaa[(_at_)stylename =
'finish'][1]/preceding-sibling::node()
[generate-id(preceding-sibling::aaa[(_at_)stylename = 'start'][1]) =
generate-id(current())]"/>
</xsl:copy>
<xsl:apply-templates select="following-sibling::aaa[(_at_)stylename =
'finish'][1]"/>
</xsl:template>
<xsl:template match="aaa[(_at_)stylename = 'finish']">
<xsl:apply-templates select="following-sibling::node()[1]"/>
</xsl:template>
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
--~------------------------------------------------------------------
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>
--~--