Re: A small stress test

Sorry,

It looks to me more an XSLT stress test, isn'it ?

Mohamed

On Nov 30, 2007 7:40 PM, Richard Tobin <richard@inf.ed.ac.uk> wrote:

>
> The pipeline below computes Ackermann's function.  For example,
> given the input file
>
>  <a><m>3</m><n>1</n></a>
>
> it produces the output
>
>  <x>13</x>
>
> Given the input
>
>  <a><m>3</m><n>2</n></a>
>
> it should produce
>
>  <x>29</x>
>
> but with my implementation produces "fork: Resource temporarily
> unavailable".
>
> <p:pipeline name="ackermann" xmlns:p="http://www.w3.org/ns/xproc">
>
> <p:input port="in"/>
> <p:output port="out"/>
>
> <p:xslt name="transform">
>  <p:input port="stylesheet">
>    <p:inline>
>
> <xsl:stylesheet version="1.0" xmlns:xsl="
> http://www.w3.org/1999/XSL/Transform">
>  <xsl:template match="node()">
>    <xsl:copy>
>      <xsl:apply-templates select="node()"/>
>    </xsl:copy>
>  </xsl:template>
>
>  <xsl:template match="a[.//a]" priority="10">
>    <xsl:copy>
>      <xsl:apply-templates select="node()"/>
>    </xsl:copy>
>  </xsl:template>
>
>  <xsl:template match="a[m=0]">
>    <x>
>      <xsl:value-of select="n + 1"/>
>    </x>
>  </xsl:template>
>
>  <xsl:template match="a[m>0 and n=0]">
>    <a>
>      <m><xsl:value-of select="m - 1"/></m>
>      <n>1</n>
>    </a>
>  </xsl:template>
>
>  <xsl:template match="a[m>0 and n>0]">
>    <a>
>      <m><xsl:value-of select="m - 1"/></m>
>      <n>
>        <a>
>          <m><xsl:value-of select="m"/></m>
>          <n><xsl:value-of select="n - 1"/></n>
>        </a>
>      </n>
>    </a>
>
>  </xsl:template>
> </xsl:stylesheet>
>
>    </p:inline>
>  </p:input>
> </p:xslt>
>
> <p:choose name="choose">
>  <p:when test="//a" name="when">
>    <ackermann name="rec-ack"/>
>  </p:when>
>  <p:otherwise name="otherwise">
>    <p:identity name="identity"/>
>  </p:otherwise>
> </p:choose>
>
> </p:pipeline>
>
> -- Richard
>
>


-- 
Innovimax SARL
Consulting, Training & XML Development
9, impasse des Orteaux
75020 Paris
Tel : +33 9 52 475787
Fax : +33 1 4356 1746
http://www.innovimax.fr
RCS Paris 488.018.631
SARL au capital de 10.000 €

Received on Friday, 30 November 2007 18:57:00 UTC