xsl-list
[Top] [All Lists]

Re: [xsl] axis specifier issue

2009-10-30 13:20:45
a kusa wrote:
What I want is that any <note> element that is below <desc> and before<prt2>
to be pushed under <prt2>.

With XSLT 2.0 you can achieve that as follows:

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="2.0">

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@*, node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="prt1">
    <xsl:copy>
<xsl:apply-templates select="@*, node() except note[. &gt;&gt; current()/desc[1] and . &lt;&lt; current()/prt2[1]]"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="prt2">
    <xsl:copy>
<xsl:apply-templates select="@*, preceding-sibling::note[. &gt;&gt; current()/preceding-sibling::desc[1]], node()"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

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