MudGuard: Alter in Jahren ...

Hi,

ich bitte mal um Code-Kontrolle.
Das XSLT soll anhand des Geburtstags (birthday-Element, ISO-Date-Format, Bereich zwischen 1900 und 1999) das Alter in Jahren ausrechnen zu einem gegebenen Stichtag (ultimatum-Element, ISO-Date-Format, Bereich ab heute bis 2030)

So sieht ein (aufs nötigste reduziertes) Input-XML aus:

  
<data>  
  <birthday>1966-12-06</birthday>  
  <ultimatum>2006-11-06</ultimatum>  
</data>  

Und so mein Code, der gibt birthday, ultimatum und das alter (in Jahren) aus:

  
<?xml version="1.0" encoding="iso-8859-1"?>  
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">  
  <xsl:template match="/data">  
    <data>  
      <birthday><xsl:value-of select="birthday"/></birthday>  
      <ultimatum><xsl:value-of select="ultimatum"/></ultimatum>  
      <age>  
        <xsl:call-template name="age">  
          <xsl:with-param name="bday" select="birthday"/>  
          <xsl:with-param name="uday" select="ultimatum"/>  
        </xsl:call-template>  
      </age>  
    </data>  
  </xsl:template>  
  
  <xsl:template name="age">  
    <xsl:param name="bday"/>  
    <xsl:param name="uday"/>  
    <xsl:variable name="bdayAFTERuday">  
      <xsl:choose> <!-- if birthday(without year)  > ultimatum(without year): reduce by one -->  
        <xsl:when test="concat(substring($bday,6,2), substring($bday,9,2))  
                        > concat(substring($uday,6,2), substring($uday,9,2))">1</xsl:when>  
        <xsl:otherwise>0</xsl:otherwise>  
      </xsl:choose>  
    </xsl:variable>  
    <xsl:value-of select="substring($uday,1,4) - substring($bday,1,4) - $bdayAFTERuday"/>  
  </xsl:template>  
</xsl:stylesheet>  
  

In allen meinen Testfällen hat's gepaßt - aber vielleicht hab ich ja wesentliches übersehen und meine Testfälle sind nicht ausreichend ...

cu,
Andreas

--
Warum nennt sich Andreas hier MudGuard?
Schreinerei Waechter
O o ostern ...
Fachfragen unaufgefordert per E-Mail halte ich für unverschämt und werde entsprechende E-Mails nicht beantworten. Für Fachfragen ist das Forum da.