ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
[xsl] Re: Re: Re: lookup-table thoughts (was Re: matching multiple times, outputting once?
by Dimitre Novatchev other posts by this author
Nov 7 2001 2:00PM messages near this date
RE: [xsl] Relative path in include statement | Re: [xsl] Re: Re: Re: lookup-table thoughts (was Re: matching multiple times, outputting once?
Jeni Tennison <jeni at jenitennison dot com>  wrote:


David,

[reply to David skipped]

And for Dimitre:

>  <xsl:template name="writeLines">
>    <xsl:param name="number" select="1000" />
>    <xsl:param name="line">
>      I should understand loops as being syntax for a simple form of
>      recursion.
>    </xsl:param>
>    <xsl:choose>
>      <xsl:when test="not($number mod 5)">
>        <xsl:call-template name="writeLines">
>          <xsl:with-param name="number" select="$number div 5" />
>          <xsl:with-param name="line"
>            select="concat($line, $line, $line, $line, $line)" />
>        </xsl:call-template>
>      </xsl:when>
>      <xsl:when test="not($number mod 2)">
>        <xsl:call-template name="writeLines">
>          <xsl:with-param name="number" select="$number div 2" />
>          <xsl:with-param name="line" select="concat($line, $line)" />
>        </xsl:call-template>
>      </xsl:when>
>      <xsl:otherwise>
>        <xsl:value-of select="$line" />
>      </xsl:otherwise>
>    </xsl:choose>
>  </xsl:template>

Obviously Jeni's reflection of me needs updating...

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:pGenerator="pGenerator"
xmlns:pController="pController"
exclude-result-prefixes="xsl pGenerator pController"
> 
  <xsl:import href="buildListWhile.xsl"/> 

  <xsl:output indent="yes" omit-xml-declaration="yes"/> 

  <pGenerator:pGenerator/> 
  <pController:pController/> 

  <xsl:variable name="vMyGenerator" select="document('')/*/pGenerator:*[1]"/> 
  <xsl:variable name="vMyController" select="document('')/*/pController:*[1]"/> 

  <xsl:template match="/"> 
    <xsl:call-template name="buildListWhile"> 
      <xsl:with-param name="pGenerator" select="$vMyGenerator"/> 
      <xsl:with-param name="pController" select="$vMyController"/> 
      <xsl:with-param name="pContollerParam" select="1000"/> 
      <xsl:with-param name="pElementName" select="'indoctrinate'"/> 
    </xsl:call-template> 
  </xsl:template> 

  <xsl:template name="listGenerator" match="*[namespace-uri()='pGenerator']"> 
     <xsl:param name="pList" select="/.."/> 
     <xsl:param name="pParams"/> 
     I should understand loops as being syntax for a simple form of
     recursion.
  </xsl:template> 

  <xsl:template name="listController" match="*[namespace-uri()='pController']"> 
     <xsl:param name="pList" select="/.."/> 
     <xsl:param name="pParams"/> 

     <xsl:if test="count($pList) &lt;= $pParams"> 1</xsl:if>
  </xsl:template> 

</xsl:stylesheet> 


As you can notice, the "buildListWhile" function (oopsss... template) is generic
enough to incorporate any future indoctrinations. Actually its real purpose is to
help in simulating Haskell's lazy evaluation of infinite data structures, and
especially to be used in implementing the "take", takeWhile" etc. family of Haskell
functions.

Cheers,
Dimitre Novatchev.

__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Thread:
Dimitre Novatchev
Jeni Tennison
Dimitre Novatchev
David Carlisle
Jeni Tennison

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved