Subject: Re: [xsl] General algorithm for finding nodes between PIs From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 26 Jan 2017 22:41:04 -0000 |
I think this could be simplified: > <xsl:template match="*[processing-instruction('Fm')[starts-with(., 'Condstart')]]"> > <xsl:for-each-group select="node()" group-starting-with="processing-instruction('Fm')[starts-with(., 'Condstart')]"> > <xsl:if test="self::processing-instruction('Fm')[starts-with(., 'Condstart')]"> > <group name="{.}"> > <xsl:variable name="pi-end-name" select="replace(., 'Condstart', 'Condend')"/> > <xsl:variable name="end" select="following-sibling::processing-instruction('Fm')[. = $pi-end-name][1]"> > <xsl:copy-of select="current-group()[. << $end]"/> > </group> > </xsl:if> > </xsl:for-each-group> > <xsl:apply-templates/> > </xsl:template> Michael Kay Saxonica > > Like this: > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > exclude-result-prefixes="xs" > version="2.0"> > > <xsl:template match="/"> > <results> > <xsl:apply-templates/> > </results> > </xsl:template> > > <xsl:template match="*[processing-instruction('Fm')[starts-with(., 'Condstart')]]"> > <xsl:for-each-group select="node()" group-starting-with="processing-instruction('Fm')[starts-with(., 'Condstart')]"> > <xsl:if test="self::processing-instruction('Fm')[starts-with(., 'Condstart')]"> > <group name="{.}"> > <xsl:variable name="pi-end-name" select="replace(., 'Condstart', 'Condend')"/> > <xsl:for-each-group select="current-group() except ." group-ending-with="processing-instruction('Fm')[. = $pi-end-name]"> > <xsl:if test="current-group()[last()][self::processing-instruction('Fm')[. = $pi-end-name]]"> > <xsl:copy-of select="current-group()[position() ne last()]"/> > </xsl:if> > </xsl:for-each-group> > </group> > </xsl:if> > </xsl:for-each-group> > <xsl:apply-templates/> > </xsl:template> > > <xsl:template match="text()"/> > > </xsl:stylesheet>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] General algorithm for fin, Martin Honnen martin | Thread | Re: [xsl] General algorithm for fin, Rick Quatro rick@xxx |
Re: [xsl] General algorithm for fin, Martin Honnen martin | Date | Re: [xsl] General algorithm for fin, Rick Quatro rick@xxx |
Month |