I had to get help on this one :)
Basically you need to select all the SHRow elements and then process all the MD_Row1 following sibling elements that have their immediately previous SHRow equal to the current SHRow:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="MD_Body">
<xsl:copy>
<xsl:apply-templates select="SHRow"/>
</xsl:copy>
</xsl:template>
<xsl:template match="SHRow">
<xsl:copy>
<xsl:apply-templates select="following-sibling::MD_Row1[generate-id(preceding-sibling::SHRow[1]) = generate-id(current())]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="MD_Row1">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
You can also do it by treating it as a value based grouping problem. Examples of this are at:
http://www.jenitennison.com/xslt/grouping/index.html
Joe (MVP -xml)