English | Français | >> Deutsch << | Magyar | 中文 | Polski | ZVON > Tutorials > XSLT Tutorial |
Intro / Suchen / ZVON |
>> Seite 47 << | Zurück | Vor | Inhalt | Element-Index |
XML Quelltext
<source> <number>9</number> <number>0</number> <number>-9</number> <number/> </source> Ausgabe
<P>9</P> <P>NaN</P> <P>9/0 = Infinity</P> <P>-9/0 = -Infinity</P> <P>0/0 = NaN</P> HTML-Ansicht
9 NaN 9/0 = Infinity -9/0 = -Infinity 0/0 = NaN |
XSLT Stylesheet
<xsl:stylesheet version = '1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:variable name="A" select="number(//number[1])"/> <xsl:variable name="B" select="number(//number[2])"/> <xsl:variable name="C" select="number(//number[3])"/> <xsl:variable name="D" select="number(//number[4])"/> <xsl:template match="/"> <P> <xsl:value-of select="string(number($A))"/> </P> <P> <xsl:value-of select="string(number($D))"/> </P> <P> <xsl:value-of select="$A"/> <xsl:text>/</xsl:text> <xsl:value-of select="$B"/> <xsl:text> = </xsl:text> <xsl:value-of select="string($A div $B)"/> </P> <P> <xsl:value-of select="$C"/> <xsl:text>/</xsl:text> <xsl:value-of select="$B"/> <xsl:text> = </xsl:text> <xsl:value-of select="string($C div $B)"/> </P> <P> <xsl:value-of select="$B"/> <xsl:text>/</xsl:text> <xsl:value-of select="$B"/> <xsl:text> = </xsl:text> <xsl:value-of select="$B div $B"/> </P> </xsl:template> </xsl:stylesheet> |