<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xsl:template name="add" match="add">
		<xsl:apply-templates mode="adder" select="*[1]">
			<xsl:with-param name="rest" select="*[2]"/>
		</xsl:apply-templates>
	</xsl:template>

	<!-- add Succ(x) y = Succ(add x y) -->
	<xsl:template name="addSucc" mode="adder" match="Succ">
		<xsl:param name="rest"/>
		<Succ>
			<xsl:apply-templates mode="adder">
				<xsl:with-param name="rest" 
select="$rest"/>
			</xsl:apply-templates>
		</Succ>
	</xsl:template>

	<!-- add Zero y = y -->
	<xsl:template name="addZero" mode="adder" match="Zero">
		<xsl:param name="rest"/>
		<xsl:copy-of select="$rest"/>
	</xsl:template>

</xsl:stylesheet>

