Subject: Re: [xsl] Extracting a fragment between milestones from a complex structure. From: Jeroen Hellingman <jeroen@xxxxxxxx> Date: Thu, 03 Mar 2011 21:06:09 +0100 |
Thanks David, that does the trick. Since their is no guaranty that the @n attributes are in order, I've adjusted the solution a little to look up the next pb element; but it would be even nicer if that too could be avoided, also using explicit priorities to avoid excessive warnings. Works both with XSLT 1.0 and 2.0, which makes it easier to deploy on my site. Jeroen. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:param name="n" select="12"/> <xsl:variable name="m"> <xsl:value-of select="//pb[@n=$n]/following::pb[1]/@n"/> </xsl:variable> <xsl:template match="node()" priority="1"/> <xsl:template match="*[descendant-or-self::pb/@n=$n] | node()[preceding::pb/@n=$n]" priority="2"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="node()[preceding::pb/@n=$m or self::pb/@n=$m]" priority="3"/> </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Reusing and XPath express, Dimitre Novatchev | Thread | [xsl] xpath expression restriction, ac |
Re: [xsl] Reusing and XPath express, Dimitre Novatchev | Date | [xsl] xpath expression restriction, ac |
Month |