Sabtu, 27 Desember 2025

XML - XSL - JS - WSH

 



fact.xsl

<?xml version='1.0' ?>

<!-- 


 fact.xsl


 if this code works, it was written by Don Box


-->


<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' 

xmlns:xsd='http://www.w3.org/1999/XMLSchema' 

version='1.0'

>

  <xsl:output method='text' />


  <xsl:param name='label' />

  <xsl:param name='num' select='5'/>


  <xsl:template name='fact' >

    <xsl:param name='n' />

    <xsl:param name='tally' select='1'/>

    <xsl:if test='$n > 0' >

      <xsl:call-template name='fact' >

        <xsl:with-param name='n' select='$n - 1' />

        <xsl:with-param name='tally' select='$n * $tally' />

      </xsl:call-template>

    </xsl:if>

    <xsl:if test='$n = 0' >

      <xsl:value-of select='$tally'/>

    </xsl:if>

  </xsl:template>

  <xsl:template match='/' >

    <xsl:value-of select='$label' />

    <xsl:text xml:space='preserve'>

</xsl:text>

    <xsl:value-of select='$num' />

    <xsl:text>! = </xsl:text>

    <xsl:call-template name='fact' >

      <xsl:with-param name='n' select='$num' />

    </xsl:call-template>

  </xsl:template>



</xsl:stylesheet>

======================================

fact.js


Tidak ada komentar: