|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: Re: lookup-table thoughts (was Re: matching mu
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) <= $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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








