Domanda abbastanza semplice, come posso trasformare un numero (1, 2, 3, ecc.) in un numero ordinale stampabile (1 °, 2 °, 3 ° ecc.) usando xslt?Come trasformare un numero (1,2,3, ecc.) In un numero ordinale (1 °, 2 °, 3 ° ecc.) Usando xslt
Attualmente i seguenti lavori per 1-20, ma si può essere visto più grandi insiemi di entità ottenere classificato presto:
<xsl:template name="FormatRanking">
<xsl:param name="Value"></xsl:param>
<xsl:choose>
<xsl:when test="$Value = '1'">
<xsl:value-of select="$Value"/>st
</xsl:when>
<xsl:when test="$Value = '2'">
<xsl:value-of select="$Value"/>nd
</xsl:when>
<xsl:when test="$Value = '3'">
<xsl:value-of select="$Value"/>rd
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Value"/>th
</xsl:otherwise>
</xsl:choose>
</xsl:template>
L'unico modo vorrei sapere come fare questo sarebbe quello di cambiare il xsl: quando di :
<xsl:when test="$Value = '1'">
<xsl:when test="$Value = '2'">
<xsl:when test="$Value = '3'">
a (non sono nemmeno sicuro se questo è corretto):
<xsl:when test="$Value = '1' or $Value = '21' or $Value = '31' ...">
<xsl:when test="$Value = '2' or $Value = '22' or $Value = '33' ...">
<xsl:when test="$Value = '3' or $Value = '22' or $Value = '33' ...">
mi piacerebbe farlo mething simile a questo Is there an easy way to create ordinals in C#? ma non sono sicuro che sia possibile in Xslt.
A questo punto abbiamo solo bisogno di una soluzione inglese.
La tua fiducia nelle capacità di XSLT è commovente, se selvaggiamente non realistico – skaffman
@skaffman: Immagino tu stia sottovalutando le capacità di XSLT. – Tomalak
Dopotutto, XSLT dovrebbe essere completato. – Eric