Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XSLT coding
Message
 
À
10/10/2007 15:00:10
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01260126
Message ID:
01268081
Vues:
11
Hi, Sam

The current XML and XSLT versions don't handle dates very well. XSLT 2 is supposed to understand dates as first class citizens. For now, if we want to handle date semantics into our XML and XSLT documents, we need to create dates following the ISO 8601 specification. This basically means treating dates as strings on the format "YYYYMMDD".

The following XSL transformation fragment shows how we can acomplish that:
<xsl:if test="@discount_applies = 'Y'">

  <xsl:variable name="baseDate" select="20070928" />
  <xsl:variable name="itemDate" select="concat(substring(@date,7,4), substring(@date,4,2), substring(@date,1,2))" />

  <xsl:choose>
    <xsl:when test ="$itemDate >= $baseDate"></xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="discountvalue" />
      <xsl:text> </xsl:text>
      <xsl:value-of select="@disc_value - @mk_value" />
    </xsl:otherwise>
  </xsl:choose>

</xsl:if>
Just out of curiosity, when LINQ to XML is out, we will be able to handle dates more easily in .NET programs.
-----
Fabio Vazquez
http://www.fabiovazquez.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform