xsl-list
[Top] [All Lists]

Re: AW: Translating roman numerals into integers with XSLT 2.0

2004-12-21 10:06:59
Of course, the XSLT 2.0 stylesheet will not work with
1.0 processor.

We need to write a different stylesheet for XSLT 1.0
processors. The only change will be, that we need to
write a named template instead of a xsl:function .. I
am presenting below a XSLT 1.0 solution also..

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
    
<xsl:output method="text"/>
    
<xsl:template match="/">
  <xsl:call-template name="RomanToInteger">
    <xsl:with-param name="roman_number" select="'XXI'"
/> 
    <xsl:with-param name="index" select="1" /> 
  </xsl:call-template>        
</xsl:template>
    
<xsl:template name="RomanToInteger">
  <xsl:param name="roman_number" />
  <xsl:param name="index" />
  <xsl:variable name="temp">
    <xsl:call-template name="toRoman">
      <xsl:with-param name="value" select="$index" /> 
       
    </xsl:call-template>        
  </xsl:variable>
  <xsl:choose>    
    <xsl:when test="$temp = $roman_number">
      <xsl:value-of select="$index" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="RomanToInteger">
        <xsl:with-param name="roman_number"
select="$roman_number" /> 
        <xsl:with-param name="index" select="$index +
1" /> 
      </xsl:call-template>
    </xsl:otherwise>
  </xsl:choose>  
</xsl:template>
    
<xsl:template name="toRoman">
  <xsl:param name="value"/>
  <xsl:number value="$value" format="I"/>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

Von: António Mota [mailto:xptm(_at_)sapo(_dot_)pt] 
Gesendet: Dienstag, 21. Dezember 2004 17:05
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: Re: [xsl] Translating roman numerals into
integers 
with XSLT 2.0

1) It works only with XSLT 2.0 as the Subject
sugests or with 1.0 too?





                
__________________________________ 
Do you Yahoo!? 
Jazz up your holiday email with celebrity designs. Learn more. 
http://celebrity.mail.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>