Re: [xsl] if a condition is not met

Subject: Re: [xsl] if a condition is not met
From: George Cristian Bina <george@xxxxxxxxxxxxx>
Date: Tue, 15 May 2007 23:50:40 +0300
Here it is a 2.0 solution following the same idea as the 1.0 solution but using a function and a call to that function.

<xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:g="http://www.oxygenxml.com/george";>
    <xsl:output indent="yes"/>

<xsl:function name="g:freeTimes">
<xsl:param name="time"/>
<xsl:param name="cell"/>
<xsl:sequence select="
if ($time/@time=$cell/@startTime) then
(g:freeTimes( $time/following-sibling::time[@time=$cell/@endTime], $cell/following-sibling::cell[1]) )
else if ($time/following-sibling::*) then ($time, g:freeTimes($time/following-sibling::time[1], $cell)) else ()
"/>
</xsl:function>
<xsl:template match="/*">
<free><xsl:copy-of select="g:freeTimes(times/time[1], cells/cell[1])"/></free>
</xsl:template>
</xsl:stylesheet>


Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Abel Braaksma wrote:
Michael Kay wrote:
This will almost certainly be easier in XSLT 2.0 than in 1.0. Would you be
content with a 2.0 solution?

my thoughts exactly. But I did such a poor attempt that George C Bina's XSLT 1.0 solution looks far more elegant and simpler than my XSLT 2.0 version.... :D

Current Thread