Hi,
Tempore 11:41:35, die 09/22/2005 AD, hinc in
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit geoff hopkins
<geoffhopkins123(_at_)yahoo(_dot_)com>:
<root>
<item>Z</item>
<item>A</item>
<item>B</item>
<item>C</item>
<item>BOB1</item>
<item>BOB2</item>
<item>BOB3</item>
<item>BOB4</item>
<item>D</item>
<item>BOB5</item>
<item>BOB6</item>
<item>A</item>
<item>BOB7</item>
<item>B</item>
<item>BOB8</item>
<item>C</item>
<item>BOB9</item>
<item>B</item>
<item>BOB10</item>
</root>
output would look something like this
<root>
<item>BOB1</item>
<item>BOB2</item>
<item>BOB3</item>
<item>BOB4</item>
</root>
I think this would work:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates select="item[1]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="item[.='A']">
<xsl:apply-templates select="(following-sibling::item[1][.='B']|
following-sibling::item[.='A'][1])[1]"/>
</xsl:template>
<xsl:template match="item[.='B']">
<xsl:apply-templates select="(following-sibling::item[1][.='C']|
following-sibling::item[.='A'][1])[1]"/>
</xsl:template>
<xsl:template match="item">
<xsl:copy-of select="."/>
<xsl:apply-templates select="following-sibling::item[1]"/>
</xsl:template>
<xsl:template match="item[.='Z' or .='C']">
<xsl:apply-templates select="following-sibling::item[1]"/>
</xsl:template>
<xsl:template match="item[.='D']">
<xsl:apply-templates select="following-sibling::item[.='A'][1]"/>
</xsl:template>
</xsl:stylesheet>
Most likely, it is possible to create a more generic solution, but I don't know
to what extent your real XML differs from your examples.
regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
«Error, keyboard not found— press F1 to continue» , BIOS
--~------------------------------------------------------------------
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>
--~--