[xsl] Re: xsl-list Digest 23 Jan 2006 06:10:00 -0000 Issue 668

Subject: [xsl] Re: xsl-list Digest 23 Jan 2006 06:10:00 -0000 Issue 668
From: Phillip B Oldham <phillip.oldham@xxxxxxxxxx>
Date: Thu, 26 Jan 2006 13:24:29 +0000
Hi.

I've given this a go, but the context its being used in is causing problems.

Is there any way I can convert this so that I use <xsl:call-template /> instead of <xsl:apply-templates />? I've tried to convert it, but I just get 500 errors from the web-server (this is being processed by PHP5).

Thanks.

Date: Mon, 23 Jan 2006 01:10:55 +0100
To:  xsl-list@xxxxxxxxxxxxxxxxxxxxxx
From: "mnews-xsl@xxxxxx" <mnews-xsl@xxxxxx>
Subject: RE: SQL BTree to XML Tree?
Message-ID: <43D41F0F.30407@xxxxxx>

Hello,

the following is intended to work in XSLT 1.0 (libxslt):
It's a recursive template, hopefully not to wastefull on the ressources.

<?xml version="1.0" encoding="utf8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

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

<!-- Conditions equivalent to
   <xsl:sequence select="$boss/../item[lh gt $boss/lh and rh le $boss/rh]"/>
-->

<xsl:template match="item">
   <xsl:param name="context"/>
   <xsl:if test="not($context[current()/lh > lh and rh >= current()/rh])">
     <xsl:variable name="context-inner"
       select="$context[lh > current()/lh and current()/rh >= rh]"/>
     <department title="{name}">
       <xsl:apply-templates select="$context-inner">
         <xsl:with-param name="context" select="$context-inner"/>
       </xsl:apply-templates>
     </department>
   </xsl:if>
</xsl:template>

<xsl:template match="/">
   <group>
     <xsl:apply-templates select="output/item">
       <xsl:with-param name="context" select="output/item"/>
     </xsl:apply-templates>
   </group>
</xsl:template>

</xsl:stylesheet>

Current Thread