Subject: Re: [xsl] Selecting everything "before" and "after" a specific node From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 2 Apr 2009 12:51:17 +0100 |
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:strip-space elements="*"/> <xsl:output indent="yes"/> <xsl:variable name="this" select="//E[@i='9']"/> <xsl:template match="/"> <ROOT> <BEFORE> <xsl:apply-templates mode="before"/> </BEFORE> <PULLED> <xsl:copy-of select="$this"/> </PULLED> <AFTER> <xsl:apply-templates mode="after"/> </AFTER> </ROOT> </xsl:template> <xsl:template match="*[. is $this]" mode="before after" priority="3"/> <xsl:template match="*[. >> $this]" mode="before" priority="2"/> <xsl:template match="*" mode="before after"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="#current"/> </xsl:copy> </xsl:template> <xsl:variable name="before" select="$this/preceding::*"/> <xsl:template match="*[$before[. is current()]]" mode="after" priority="2"/> </xsl:stylesheet> $ saxon9 pull.xml pull.xsl <?xml version="1.0" encoding="UTF-8"?> <ROOT> <BEFORE> <A i="1"> <B i="2"> <C i="3"/> </B> <B i="4"> <C i="5"> <D i="6"/> <D i="7"> <E i="8"/> </D> </C> </B> </A> </BEFORE> <PULLED> <E i="9" msg="get me out of here!"/> </PULLED> <AFTER> <A i="1"> <B i="4"> <C i="5"> <D i="7"> <E i="10"/> </D> <D i="11"/> </C> <C i="12"/> </B> </A> </AFTER> </ROOT> ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Selecting everything "bef, Emmanuel Bégué | Thread | Re: [xsl] Selecting everything "bef, Martin Honnen |
RE: [xsl] Selecting everything "bef, Emmanuel Bégué | Date | Re: [xsl] Selecting everything "bef, Martin Honnen |
Month |