[School] Exercise xml using xsl transformation
For example, I have an xml file that contains information the coefficient of rank PT 2. Using XSL to read the data in xml PT.
<?xml version = "1.0"?> <?xml-stylesheet type="text/xsl" href="ptb2.xsl"?> <PTB2> <HeSo giatri = "1"/> <HeSo giatri = "3"/> <HeSo giatri = "2"/> </PTB2>
<?xml version = "1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math"
version="1.0">
<xsl:template match="/">
<xsl:variable name = "a" select="PTB2/HeSo[1]/@giatri"/>
<xsl:variable name = "b" select="PTB2/HeSo[2]/@giatri"/>
<xsl:variable name = "c" select="PTB2/HeSo[3]/@giatri"/>
<xsl:variable name = "delta" select="$b * $b - 4 * $a * $c"/>
<xsl:if test = "$delta < 0">
PT Vo nghiem
</xsl:if>
<xsl:if test = "$delta = 0">
PT Co nghiem kep x =
<xsl:value-of select = "-$b div 2 div $a"/>
</xsl:if>
<xsl:if test = "$delta > 0">
PT Co 2 nghiem phan biet <br/>
x1 =
<xsl:value-of select = "(-$b + math:sqrt($delta)) div 2 div $a"/>
<br/>
x2 =
<xsl:value-of select = "(-$b - math:sqrt($delta)) div 2 div $a"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>



Recent Comments