W3C home > Mailing lists > Public > public-xml-processing-model-wg@w3.org > November 2007

A small stress test

From: Richard Tobin <richard@inf.ed.ac.uk>
Date: Fri, 30 Nov 2007 18:40:47 +0000 (GMT)
To: public-xml-processing-model-wg@w3.org
Message-Id: <20071130184047.CD3B129A01A@macpro.inf.ed.ac.uk>

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
Received on Friday, 30 November 2007 18:40:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:21:54 GMT