Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#1999 - XSLT

1999 - XSLT

The World Wide Web Consortium (W3C) created XSLT for transforming XML into HTML, text, etc. The following examples assume input is enclosed in <input>..</input> tags. ##Task 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input">XSLT was made in 1999!</xsl:template> </xsl:stylesheet> This

Task 1

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">XSLT was made in 1999!</xsl:template>
</xsl:stylesheet>

This one is simple. It matches an input tag at the top level and replaces it with the desired output. ##Task 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input"> <xsl:call-template name="loop"> <xsl:with-param name="i">1</xsl:with-param> <xsl:with-param name="n"> <xsl:value-of select="."/> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="loop"> <xsl:param name="i"/> <xsl:param name="n"/> xsl:choose <xsl:when test="$i = 1 or $i = $n"> xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - 2"/> </xsl:with-param> </xsl:call-template> xsl:textN </xsl:text> </xsl:when> xsl:otherwise xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$i - 2"/> </xsl:with-param> </xsl:call-template> xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - $i - 1"/> </xsl:with-param> </xsl:call-template> xsl:textN </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="$i < $n"> <xsl:call-template name="loop"> <xsl:with-param name="i"> <xsl:value-of select="$i + 1"/> </xsl:with-param> <xsl:with-param name="n"> <xsl:value-of select="$n"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="spaces"> <xsl:param name="n"/> <xsl:if test="$n > 0"> xsl:text </xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - 1"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> This

Task 2

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="loop">
 <xsl:with-param name="i">1</xsl:with-param>
 <xsl:with-param name="n">
 <xsl:value-of select="."/>
 </xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="loop">
 <xsl:param name="i"/>
 <xsl:param name="n"/>
 <xsl:choose>
 <xsl:when test="$i = 1 or $i = $n">
 <xsl:text>N</xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$n - 2"/>
 </xsl:with-param>
 </xsl:call-template>
 <xsl:text>N&#13;&#10;</xsl:text>
 </xsl:when>
 <xsl:otherwise>
 <xsl:text>N</xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$i - 2"/>
 </xsl:with-param>
 </xsl:call-template>
 <xsl:text>N</xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$n - $i - 1"/>
 </xsl:with-param>
 </xsl:call-template>
 <xsl:text>N&#13;&#10;</xsl:text>
 </xsl:otherwise>
 </xsl:choose>
 <xsl:if test="$i &lt; $n">
 <xsl:call-template name="loop">
 <xsl:with-param name="i">
 <xsl:value-of select="$i + 1"/>
 </xsl:with-param>
 <xsl:with-param name="n">
 <xsl:value-of select="$n"/>
 </xsl:with-param>
 </xsl:call-template>
 </xsl:if>
 </xsl:template>
 <xsl:template name="spaces">
 <xsl:param name="n"/>
 <xsl:if test="$n &gt; 0">
 <xsl:text> </xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$n - 1"/>
 </xsl:with-param>
 </xsl:call-template>
 </xsl:if>
 </xsl:template>
</xsl:stylesheet>

This one defines 2 recursive templates, loop and spaces. loop with parameters i and n will generate the desired output for n, starting at position i. spaces with parameter n will generate n spaces. ##Task 3 Input

Task 3

Input for this must be in <input><num>..</num><num>..</num></input> tags.

#1999 - XSLT

The World Wide Web Consortium (W3C) created XSLT for transforming XML into HTML, text, etc. The following examples assume input is enclosed in <input>..</input> tags. ##Task 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input">XSLT was made in 1999!</xsl:template> </xsl:stylesheet> This one is simple. It matches an input tag at the top level and replaces it with the desired output. ##Task 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input"> <xsl:call-template name="loop"> <xsl:with-param name="i">1</xsl:with-param> <xsl:with-param name="n"> <xsl:value-of select="."/> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="loop"> <xsl:param name="i"/> <xsl:param name="n"/> xsl:choose <xsl:when test="$i = 1 or $i = $n"> xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - 2"/> </xsl:with-param> </xsl:call-template> xsl:textN </xsl:text> </xsl:when> xsl:otherwise xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$i - 2"/> </xsl:with-param> </xsl:call-template> xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - $i - 1"/> </xsl:with-param> </xsl:call-template> xsl:textN </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="$i < $n"> <xsl:call-template name="loop"> <xsl:with-param name="i"> <xsl:value-of select="$i + 1"/> </xsl:with-param> <xsl:with-param name="n"> <xsl:value-of select="$n"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="spaces"> <xsl:param name="n"/> <xsl:if test="$n > 0"> xsl:text </xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - 1"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> This one defines 2 recursive templates, loop and spaces. loop with parameters i and n will generate the desired output for n, starting at position i. spaces with parameter n will generate n spaces. ##Task 3 Input for this must be in <input><num>..</num><num>..</num></input> tags.

1999 - XSLT

The World Wide Web Consortium (W3C) created XSLT for transforming XML into HTML, text, etc. The following examples assume input is enclosed in <input>..</input> tags.

Task 1

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">XSLT was made in 1999!</xsl:template>
</xsl:stylesheet>

This one is simple. It matches an input tag at the top level and replaces it with the desired output.

Task 2

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="loop">
 <xsl:with-param name="i">1</xsl:with-param>
 <xsl:with-param name="n">
 <xsl:value-of select="."/>
 </xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="loop">
 <xsl:param name="i"/>
 <xsl:param name="n"/>
 <xsl:choose>
 <xsl:when test="$i = 1 or $i = $n">
 <xsl:text>N</xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$n - 2"/>
 </xsl:with-param>
 </xsl:call-template>
 <xsl:text>N&#13;&#10;</xsl:text>
 </xsl:when>
 <xsl:otherwise>
 <xsl:text>N</xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$i - 2"/>
 </xsl:with-param>
 </xsl:call-template>
 <xsl:text>N</xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$n - $i - 1"/>
 </xsl:with-param>
 </xsl:call-template>
 <xsl:text>N&#13;&#10;</xsl:text>
 </xsl:otherwise>
 </xsl:choose>
 <xsl:if test="$i &lt; $n">
 <xsl:call-template name="loop">
 <xsl:with-param name="i">
 <xsl:value-of select="$i + 1"/>
 </xsl:with-param>
 <xsl:with-param name="n">
 <xsl:value-of select="$n"/>
 </xsl:with-param>
 </xsl:call-template>
 </xsl:if>
 </xsl:template>
 <xsl:template name="spaces">
 <xsl:param name="n"/>
 <xsl:if test="$n &gt; 0">
 <xsl:text> </xsl:text>
 <xsl:call-template name="spaces">
 <xsl:with-param name="n">
 <xsl:value-of select="$n - 1"/>
 </xsl:with-param>
 </xsl:call-template>
 </xsl:if>
 </xsl:template>
</xsl:stylesheet>

This one defines 2 recursive templates, loop and spaces. loop with parameters i and n will generate the desired output for n, starting at position i. spaces with parameter n will generate n spaces.

Task 3

Input for this must be in <input><num>..</num><num>..</num></input> tags.

added 459 characters in body
Source Link
LegionMammal978
  • 18.2k
  • 4
  • 25
  • 58

The World Wide Web Consortium (W3C) created XSLT for transforming XML into HTML, text, etc. The following examples assume input is enclosed in <input>..</input> tags. ##Task 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input">XSLT was made in 1999!</xsl:template> </xsl:stylesheet> This one is simple. It matches an input tag at the top level and replaces it with the desired output. ##Task 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input"> <xsl:call-template name="loop"> <xsl:with-param name="i">1</xsl:with-param> <xsl:with-param name="n"><xslname="n"> <xsl:value-of select="."/><> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="loop"> <xsl:param name="i"/> <xsl:param name="n"/> xsl:choose <xsl:when test="$i = 1 or $i = $n"> Nxsl:textN</xsl:text> <xsl:call-template name="spaces"><xslname="spaces"> <xsl:with-param name="n"><xslname="n"> <xsl:value-of select="$n - 2"/><> </xsl:with-param><param> </xsl:call-template> N xsl:textN </xsl:text> </xsl:when> xsl:otherwise Nxsl:textN</xsl:text> <xsl:call-template name="spaces"><xslname="spaces"> <xsl:with-param name="n"><xslname="n"> <xsl:value-of select="$i - 2"/><> </xsl:with-param><param> </xsl:call-template> Nxsl:textN</xsl:text> <xsl:call-template name="spaces"><xslname="spaces"> <xsl:with-param name="n"><xslname="n"> <xsl:value-of select="$n - $i - 1"/><> </xsl:with-param><param> </xsl:call-template> N xsl:textN </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="$i < $n"> <xsl:call-template name="loop"> <xsl:with-param name="i"><xslname="i"> <xsl:value-of select="$i + 1"/><> </xsl:with-param> <xsl:with-param name="n"><xslname="n"> <xsl:value-of select="$n"/><> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="spaces"> <xsl:param name="n"/> <xsl:if test="$n > 0"> xsl:text </xsl:text> <xsl:call-template name="spaces"><xslname="spaces"> <xsl:with-param name="n"><xslname="n"> <xsl:value-of select="$n - 1"/><> </xsl:with-param><param> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> This one defines 2 recursive templates, loop and spaces. loop with parameters i and n will generate the desired output for n, starting at position i. spaces with parameter n will generate n spaces. ##Task 3 Input for this must be in <input><num>..</num><num>..</num></input> tags.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="num[1]"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="num[2]"/></xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="gcd">
 <xsl:param name="a"/>
 <xsl:param name="b"/>
 <xsl:choose>
 <xsl:when test="$atest="$b = 0"><xsl:value-of select="$b"select="$a"/></xsl:when>
 <xsl:otherwise>
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="$b"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="$a mod $b"/></xsl:with-param>
 </xsl:call-template>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>

The World Wide Web Consortium (W3C) created XSLT for transforming XML into HTML, text, etc. The following examples assume input is enclosed in <input>..</input> tags. ##Task 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input">XSLT was made in 1999!</xsl:template> </xsl:stylesheet> This one is simple. It matches an input tag at the top level and replaces it with the desired output. ##Task 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input"> <xsl:call-template name="loop"> <xsl:with-param name="i">1</xsl:with-param> <xsl:with-param name="n"><xsl:value-of select="."/></xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="loop"> <xsl:param name="i"/> <xsl:param name="n"/> xsl:choose <xsl:when test="$i = 1 or $i = $n"> N <xsl:call-template name="spaces"><xsl:with-param name="n"><xsl:value-of select="$n - 2"/></xsl:with-param></xsl:call-template> N </xsl:when> xsl:otherwise N <xsl:call-template name="spaces"><xsl:with-param name="n"><xsl:value-of select="$i - 2"/></xsl:with-param></xsl:call-template> N <xsl:call-template name="spaces"><xsl:with-param name="n"><xsl:value-of select="$n - $i - 1"/></xsl:with-param></xsl:call-template> N </xsl:otherwise> </xsl:choose> <xsl:if test="$i < $n"> <xsl:call-template name="loop"> <xsl:with-param name="i"><xsl:value-of select="$i + 1"/></xsl:with-param> <xsl:with-param name="n"><xsl:value-of select="$n"/></xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="spaces"> <xsl:param name="n"/> <xsl:if test="$n > 0"><xsl:call-template name="spaces"><xsl:with-param name="n"><xsl:value-of select="$n - 1"/></xsl:with-param></xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> This one defines 2 recursive templates, loop and spaces. loop with parameters i and n will generate the desired output for n, starting at position i. spaces with parameter n will generate n spaces. ##Task 3 Input for this must be in <input><num>..</num><num>..</num></input> tags.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="num[1]"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="num[2]"/></xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="gcd">
 <xsl:param name="a"/>
 <xsl:param name="b"/>
 <xsl:choose>
 <xsl:when test="$a = 0"><xsl:value-of select="$b"/></xsl:when>
 <xsl:otherwise>
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="$b"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="$a mod $b"/></xsl:with-param>
 </xsl:call-template>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>

The World Wide Web Consortium (W3C) created XSLT for transforming XML into HTML, text, etc. The following examples assume input is enclosed in <input>..</input> tags. ##Task 1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input">XSLT was made in 1999!</xsl:template> </xsl:stylesheet> This one is simple. It matches an input tag at the top level and replaces it with the desired output. ##Task 2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="no"/> <xsl:template match="/input"> <xsl:call-template name="loop"> <xsl:with-param name="i">1</xsl:with-param> <xsl:with-param name="n"> <xsl:value-of select="."/> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="loop"> <xsl:param name="i"/> <xsl:param name="n"/> xsl:choose <xsl:when test="$i = 1 or $i = $n"> xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - 2"/> </xsl:with-param> </xsl:call-template> xsl:textN </xsl:text> </xsl:when> xsl:otherwise xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$i - 2"/> </xsl:with-param> </xsl:call-template> xsl:textN</xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - $i - 1"/> </xsl:with-param> </xsl:call-template> xsl:textN </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:if test="$i < $n"> <xsl:call-template name="loop"> <xsl:with-param name="i"> <xsl:value-of select="$i + 1"/> </xsl:with-param> <xsl:with-param name="n"> <xsl:value-of select="$n"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="spaces"> <xsl:param name="n"/> <xsl:if test="$n > 0"> xsl:text </xsl:text> <xsl:call-template name="spaces"> <xsl:with-param name="n"> <xsl:value-of select="$n - 1"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> This one defines 2 recursive templates, loop and spaces. loop with parameters i and n will generate the desired output for n, starting at position i. spaces with parameter n will generate n spaces. ##Task 3 Input for this must be in <input><num>..</num><num>..</num></input> tags.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="num[1]"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="num[2]"/></xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="gcd">
 <xsl:param name="a"/>
 <xsl:param name="b"/>
 <xsl:choose>
 <xsl:when test="$b = 0"><xsl:value-of select="$a"/></xsl:when>
 <xsl:otherwise>
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="$b"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="$a mod $b"/></xsl:with-param>
 </xsl:call-template>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>
fixed code
Source Link
LegionMammal978
  • 18.2k
  • 4
  • 25
  • 58
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="num[1]"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="num[2]"/></xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="gcd">
 <xsl:param name="a"/>
 <xsl:param name="b"/>
 <xsl:choose>
 <xsl:when test="$a = 0"><xsl:value-of select="$b"/></xsl:when>
 <xsl:otherwise>
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="b"select="$b"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="aselect="$a mod b"$b"/></xsl:with-param>
 </xsl:call-template>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="num[1]"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="num[2]"/></xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="gcd">
 <xsl:param name="a"/>
 <xsl:param name="b"/>
 <xsl:choose>
 <xsl:when test="$a = 0"><xsl:value-of select="$b"/></xsl:when>
 <xsl:otherwise>
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="b"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="a mod b"/></xsl:with-param>
 </xsl:call-template>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="text" indent="no"/>
 <xsl:template match="/input">
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="num[1]"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="num[2]"/></xsl:with-param>
 </xsl:call-template>
 </xsl:template>
 <xsl:template name="gcd">
 <xsl:param name="a"/>
 <xsl:param name="b"/>
 <xsl:choose>
 <xsl:when test="$a = 0"><xsl:value-of select="$b"/></xsl:when>
 <xsl:otherwise>
 <xsl:call-template name="gcd">
 <xsl:with-param name="a"><xsl:value-of select="$b"/></xsl:with-param>
 <xsl:with-param name="b"><xsl:value-of select="$a mod $b"/></xsl:with-param>
 </xsl:call-template>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>
deleted 8 characters in body
Source Link
LegionMammal978
  • 18.2k
  • 4
  • 25
  • 58
Loading
Source Link
LegionMammal978
  • 18.2k
  • 4
  • 25
  • 58
Loading

AltStyle によって変換されたページ (->オリジナル) /