Re: [xsl] Re: Wrapping problem

Subject: Re: [xsl] Re: Wrapping problem
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Tue, 15 Aug 2006 17:27:03 +0530
Thanks Mike..

On 8/15/06, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> Hi Mike,
>    Can you please post this approach in more detail. I am not
> able to find anything about it on google.

Since you insist:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"

<xsl:output method="xml" indent="yes" />

<xsl:template match="/play">
   <xsl:apply-templates select="scene" />

<xsl:template match="scene">
 <scene name="{.}">
   <xsl:apply-templates select="following-sibling::character[1]"/>

<xsl:template match="character">
   <character name="{.}">
       <xsl:apply-templates select="following-sibling::*[1][self::line]"/>

<xsl:template match="line">
   <xsl:copy-of select="."/>
   <xsl:apply-templates select="following-sibling::*[1][self::line]"/>


I call the technique "sibling recursion". It's more concise than most
recursive code, because it's self-terminating: you don't need to test
explicitly whether there are more items to process, because apply-templates
does that automatically for you.

Michael Kay

-- Regards, Mukul Gandhi

Current Thread