<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Jumping through loops with XSL</title>
	<atom:link href="http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/</link>
	<description>Not anti-anything, just pro-quality</description>
	<lastBuildDate>Thu, 16 Dec 2010 07:18:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Bugfree.dk &#187; Blog Archive &#187; 2009 in retrospect</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-22119</link>
		<dc:creator>Bugfree.dk &#187; Blog Archive &#187; 2009 in retrospect</dc:creator>
		<pubDate>Mon, 28 Dec 2009 11:29:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-22119</guid>
		<description>[...] Jumping through loops with XSL [...]</description>
		<content:encoded><![CDATA[<p>[...] Jumping through loops with XSL [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matthew Holloway</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-16419</link>
		<dc:creator>Matthew Holloway</dc:creator>
		<pubDate>Fri, 17 Jul 2009 12:50:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-16419</guid>
		<description>If you know your input document has enough nodes you can also just do &lt;xsl:for-each select=&quot;//node()[position() &lt; 10]&quot;&gt;&lt;xsl:value-of select=&quot;position()&quot;/&gt;,&lt;/xsl:for-each&gt; which can be nested as much as you want (just use xsl:variables for each level).</description>
		<content:encoded><![CDATA[<p>If you know your input document has enough nodes you can also just do &lt;xsl:for-each select=&#8221;//node()[position() &lt; 10]&#8220;&gt;&lt;xsl:value-of select=&#8221;position()&#8221;/&gt;,&lt;/xsl:for-each&gt; which can be nested as much as you want (just use xsl:variables for each level).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre Novatchev</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15815</link>
		<dc:creator>Dimitre Novatchev</dc:creator>
		<pubDate>Sun, 14 Jun 2009 19:22:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15815</guid>
		<description>This is my last comment.

In order to see how powerful is XSLT 2.0 when Higher Order Functions are added to it, read this 2006 Extreme Markup Conference presentation:

http://www.idealliance.org/papers/extreme/proceedings/xslfo-pdf/2006/Novatchev01/EML2006Novatchev01.pdf</description>
		<content:encoded><![CDATA[<p>This is my last comment.</p>
<p>In order to see how powerful is XSLT 2.0 when Higher Order Functions are added to it, read this 2006 Extreme Markup Conference presentation:</p>
<p><a href="http://www.idealliance.org/papers/extreme/proceedings/xslfo-pdf/2006/Novatchev01/EML2006Novatchev01.pdf" rel="nofollow">http://www.idealliance.org/papers/extreme/proceedings/xslfo-pdf/2006/Novatchev01/EML2006Novatchev01.pdf</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre Novatchev</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15814</link>
		<dc:creator>Dimitre Novatchev</dc:creator>
		<pubDate>Sun, 14 Jun 2009 19:19:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15814</guid>
		<description>Not trying anymore to write code, here is a link to the code of f:foldl() -- the code of the function is only a few lines:

http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-foldl.xsl?revision=1.3&amp;view=markup</description>
		<content:encoded><![CDATA[<p>Not trying anymore to write code, here is a link to the code of f:foldl() &#8212; the code of the function is only a few lines:</p>
<p><a href="http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-foldl.xsl?revision=1.3&#038;view=markup" rel="nofollow">http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-foldl.xsl?revision=1.3&#038;view=markup</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mads Lindstrøm</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15810</link>
		<dc:creator>Mads Lindstrøm</dc:creator>
		<pubDate>Sun, 14 Jun 2009 16:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15810</guid>
		<description>Hi Dimitre Novatchev,

For code in comments, I have given up on Wordpress. I use http://pastebin.com/ in stead and link to the code.</description>
		<content:encoded><![CDATA[<p>Hi Dimitre Novatchev,</p>
<p>For code in comments, I have given up on WordPress. I use <a href="http://pastebin.com/" rel="nofollow">http://pastebin.com/</a> in stead and link to the code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ronnie</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15809</link>
		<dc:creator>Ronnie</dc:creator>
		<pubDate>Sun, 14 Jun 2009 16:13:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15809</guid>
		<description>@Dimitre Novatchev: 

Unfortunately, WordPress isn&#039;t too fund of code in comments.

Although I didn&#039;t mention it explicitly, I&#039;m relying on the .Net XslCompiledTransform class to do the actual transform. It only supports XSL/XPath 1.0. 

But the FXSL library is definitely worth looking into.</description>
		<content:encoded><![CDATA[<p>@Dimitre Novatchev: </p>
<p>Unfortunately, WordPress isn&#8217;t too fund of code in comments.</p>
<p>Although I didn&#8217;t mention it explicitly, I&#8217;m relying on the .Net XslCompiledTransform class to do the actual transform. It only supports XSL/XPath 1.0. </p>
<p>But the FXSL library is definitely worth looking into.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre Novatchev</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15808</link>
		<dc:creator>Dimitre Novatchev</dc:creator>
		<pubDate>Sun, 14 Jun 2009 15:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15808</guid>
		<description>Sorry, I tried twice in a row to enter some code in my comment -- how do you do it?</description>
		<content:encoded><![CDATA[<p>Sorry, I tried twice in a row to enter some code in my comment &#8212; how do you do it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitre Novatchev</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15807</link>
		<dc:creator>Dimitre Novatchev</dc:creator>
		<pubDate>Sun, 14 Jun 2009 15:32:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15807</guid>
		<description>Recursion is not the only way to implement a &quot;loop&quot; in XSLT.

In XSLT 2.0 one simply writes:


  

     &lt;!-- Whatever processing is required --&gt;

  


In XSLT 1.0 in most cases it is possible to use an elegant and efficient non-recursive technique, as described at: 

 http://www.topxml.com/code/cod-422_10050_avoiding-an-xslt-processor-crash-due-to-deep-recursive-processing.aspx

The FXSL library implements Higher Order Functions in XSLT (both in XSLT 1.0 and XSLT 2.0) and has nice functions/templates for folding, iteration, zipping, partial applications, ... etc.

Mads Lindstrøm, who commented on the code of FXSL hurting his brain, has to look at the code of FXSL 2.x (for XSLT 2.0), which is orders of magnitude simpler, because it is XSLT 2.0. For example, this is the implementation of the f:foldl() function ():



    
    
    
    
      
      
      

       1]
                              )&quot;/&gt;
    



The conclusion is: Before trying to re-invent the wheel, make an earnest attempt to read :)</description>
		<content:encoded><![CDATA[<p>Recursion is not the only way to implement a &#8220;loop&#8221; in XSLT.</p>
<p>In XSLT 2.0 one simply writes:</p>
<p>     <!-- Whatever processing is required --></p>
<p>In XSLT 1.0 in most cases it is possible to use an elegant and efficient non-recursive technique, as described at: </p>
<p> <a href="http://www.topxml.com/code/cod-422_10050_avoiding-an-xslt-processor-crash-due-to-deep-recursive-processing.aspx" rel="nofollow">http://www.topxml.com/code/cod-422_10050_avoiding-an-xslt-processor-crash-due-to-deep-recursive-processing.aspx</a></p>
<p>The FXSL library implements Higher Order Functions in XSLT (both in XSLT 1.0 and XSLT 2.0) and has nice functions/templates for folding, iteration, zipping, partial applications, &#8230; etc.</p>
<p>Mads Lindstrøm, who commented on the code of FXSL hurting his brain, has to look at the code of FXSL 2.x (for XSLT 2.0), which is orders of magnitude simpler, because it is XSLT 2.0. For example, this is the implementation of the f:foldl() function ():</p>
<p>       1]<br />
                              )&#8221;/&gt;</p>
<p>The conclusion is: Before trying to re-invent the wheel, make an earnest attempt to read :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mads Lindstrøm</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15801</link>
		<dc:creator>Mads Lindstrøm</dc:creator>
		<pubDate>Sun, 14 Jun 2009 09:36:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15801</guid>
		<description>I just googled a little and in this post http://fxsl.sourceforge.net/articles/FuncProg/2.html some guy builds up fold and map in XSL. He uses it to compute sum and product. I have not read it thoroughly, as all this XSL hurts my brain.</description>
		<content:encoded><![CDATA[<p>I just googled a little and in this post <a href="http://fxsl.sourceforge.net/articles/FuncProg/2.html" rel="nofollow">http://fxsl.sourceforge.net/articles/FuncProg/2.html</a> some guy builds up fold and map in XSL. He uses it to compute sum and product. I have not read it thoroughly, as all this XSL hurts my brain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mads Lindstrøm</title>
		<link>http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/comment-page-1/#comment-15800</link>
		<dc:creator>Mads Lindstrøm</dc:creator>
		<pubDate>Sun, 14 Jun 2009 09:22:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfree.dk/blog/2009/06/13/jumping-through-loops-with-xsl/#comment-15800</guid>
		<description>Functional languages do use recursion in stead of build-in looping constructs, but mostly only at the basic level. Typically, recursion will be used to build functions such as fold, map, scan, ... and thus hide the &quot;dangerous&quot; recursion. I say dangerous as it is easy to get wrong and end in a eternal recursion (just like eternal loops in imperative language are all too easy to make). Fold, map, and friends protect against accidentally making eternal recursion, and they make for more concise and understandable programs.

If (and I mean &#039;if&#039;, as I do not know XSL very well) do not support building map, fold, ... from basic recursion it is only functional in a negative sense. That is, it is functional as it do _not_ support destructive updates and as the programmer do not specify evaluation order. A positive definition would include things such as higher order functions, which would allow you to build fold, map, ...

If a programming language is only functional in the negative sense, I really would not want to make big and complex programs in it. It still may be very useful, but it will have it limits that it will be quite painful to cross. For example, a spreadsheet is functional in the negative sense, but not in the positive sense. And a spreadsheet is immensely useful for certain tasks, but you do not want to write the next Linux kernel in Excel. A similar argument could be made for SQL, except various extension do contain functional / imperative aspects.

The point of my rant, is that you may want to consider if XSL is really up to the task of complex processing. Of cause, as I do not know the task, nor XSL, well enough, I can have no opinion on your exact problem.</description>
		<content:encoded><![CDATA[<p>Functional languages do use recursion in stead of build-in looping constructs, but mostly only at the basic level. Typically, recursion will be used to build functions such as fold, map, scan, &#8230; and thus hide the &#8220;dangerous&#8221; recursion. I say dangerous as it is easy to get wrong and end in a eternal recursion (just like eternal loops in imperative language are all too easy to make). Fold, map, and friends protect against accidentally making eternal recursion, and they make for more concise and understandable programs.</p>
<p>If (and I mean &#8216;if&#8217;, as I do not know XSL very well) do not support building map, fold, &#8230; from basic recursion it is only functional in a negative sense. That is, it is functional as it do _not_ support destructive updates and as the programmer do not specify evaluation order. A positive definition would include things such as higher order functions, which would allow you to build fold, map, &#8230;</p>
<p>If a programming language is only functional in the negative sense, I really would not want to make big and complex programs in it. It still may be very useful, but it will have it limits that it will be quite painful to cross. For example, a spreadsheet is functional in the negative sense, but not in the positive sense. And a spreadsheet is immensely useful for certain tasks, but you do not want to write the next Linux kernel in Excel. A similar argument could be made for SQL, except various extension do contain functional / imperative aspects.</p>
<p>The point of my rant, is that you may want to consider if XSL is really up to the task of complex processing. Of cause, as I do not know the task, nor XSL, well enough, I can have no opinion on your exact problem.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

