[Home] [By Thread] [By Date] [Recent Entries]
Paul Harvey wrote:
Hi, Ibve searched and posted on another list, but have not found an answer to this problemb& I have XML like this... Here is an attempt with XSLT 2.0: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:variable name="pn" select="//*[@i = '9']"/> <xsl:template match="/">
<ROOT>
<BEFORE>
<xsl:apply-templates select="*" mode="before"/>
</BEFORE>
<PULLED_OUT>
<xsl:copy-of select="$pn"/>
</PULLED_OUT>
<AFTER>
<xsl:apply-templates select="*" mode="after"/>
</AFTER>
</ROOT>
</xsl:template><xsl:template match="*[. >> $pn or . is $pn]" mode="before"/> <xsl:template match="*[. is $pn or empty(. intersect $pn/ancestor::*) and empty(. intersect $pn/following-sibling::*)]" mode="after"/> <xsl:template match="*" mode="before">
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="before"/>
</xsl:copy>
</xsl:template> <xsl:template match="*" mode="after">
<xsl:copy>
<xsl:apply-templates select="@* | node()" mode="after"/>
</xsl:copy>
</xsl:template><xsl:template match="@* | text() | comment() | processing-instruction()" mode="after before"> <xsl:copy/> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://JavaScript.FAQTs.com/
|

Cart



