本实例目的:转义字符的用法













<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!--找出姓李的学生:-->
<xsl:apply-templates select="//学生[starts-with(姓名,'李')]" />
<br/>
<!--找出不姓李的学生:-->
<xsl:apply-templates select="//学生[not(starts-with(姓名,'李'))]" />
</xsl:template>
<xsl:template match="//学生[starts-with(姓名,'李')]">
<xsl:value-of select="姓名" />
</xsl:template>
<xsl:template match="//学生[not(starts-with(姓名,'李'))]">
<xsl:value-of select="姓名" />
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!--找出姓李的学生:-->
<xsl:apply-templates select="//学生[starts-with(姓名,'李')]" />
<br/>
<!--找出不姓李的学生:-->
<xsl:apply-templates select="//学生[not(starts-with(姓名,'李'))]" />
</xsl:template>
<xsl:template match="//学生[starts-with(姓名,'李')]">
<xsl:value-of select="姓名" />
</xsl:template>
<xsl:template match="//学生[not(starts-with(姓名,'李'))]">
<xsl:value-of select="姓名" />
</xsl:template>
</xsl:stylesheet>






















<?
xml version="1.0" encoding="gb2312"
?>
< xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" >
< xsl:template match ="/" >
<!-- (if条件测试)以不同颜色显示学生的成绩: -->
< br />
< xsl:apply-templates select ="//学生" />
</ xsl:template >
< xsl:template match ="//学生" >
< xsl:if test ="分数 = 100" >
< p style ="color:#FF0000" > 分数: < xsl:value-of select ="分数" /> 无敌 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 90 and 分数 < 100" >
< p style ="color:#FF9900" > 分数: < xsl:value-of select ="分数" /> 无畏 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 80 and 分数 < 90" >
< p style ="color:#009900" > 分数: < xsl:value-of select ="分数" /> 无问 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 70 and 分数 < 80" >
< p style ="color:#009966" > 分数: < xsl:value-of select ="分数" /> 无恐 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 60 and 分数 < 70" >
< p style ="color:#00CCCC" > 分数: < xsl:value-of select ="分数" /> 无羞 </ p >
</ xsl:if >
< xsl:if test ="分数 < 60" >
< p style ="color:red" > 分数: < xsl:value-of select ="分数" /> 无耻 </ p >
</ xsl:if >
</ xsl:template >
</ xsl:stylesheet >
< xsl:stylesheet version ="1.0" xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" >
< xsl:template match ="/" >
<!-- (if条件测试)以不同颜色显示学生的成绩: -->
< br />
< xsl:apply-templates select ="//学生" />
</ xsl:template >
< xsl:template match ="//学生" >
< xsl:if test ="分数 = 100" >
< p style ="color:#FF0000" > 分数: < xsl:value-of select ="分数" /> 无敌 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 90 and 分数 < 100" >
< p style ="color:#FF9900" > 分数: < xsl:value-of select ="分数" /> 无畏 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 80 and 分数 < 90" >
< p style ="color:#009900" > 分数: < xsl:value-of select ="分数" /> 无问 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 70 and 分数 < 80" >
< p style ="color:#009966" > 分数: < xsl:value-of select ="分数" /> 无恐 </ p >
</ xsl:if >
< xsl:if test ="分数 >= 60 and 分数 < 70" >
< p style ="color:#00CCCC" > 分数: < xsl:value-of select ="分数" /> 无羞 </ p >
</ xsl:if >
< xsl:if test ="分数 < 60" >
< p style ="color:red" > 分数: < xsl:value-of select ="分数" /> 无耻 </ p >
</ xsl:if >
</ xsl:template >
</ xsl:stylesheet >





















