如何解决如何解决xml无法在元素上显示样式的问题?
问题:-尽管正确链接了students.xsl样式表,但students.xml仍未在浏览器上显示样式。 我已经在下面提供了students.xml和students.xsl代码。请检查代码并告诉我代码问题。我是xml和xslt的新手,我只需要帮助。我正在使用Microsoft Edge和chrome浏览器。
students.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href ="students.xsl"?>
<students>
<student>
<rollno>589</rollno>
<studentname>Vihang Kale</studentname>
<coursename>MscCA</coursename>
<totalmarks>7.5</totalmarks>
<academicyear>2020-2021</academicyear>
</student>
</students>
students.xsl
<?xml version = "1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">
<xsl:template match ="/">
<html>
<body>
<xsl:apply-templates select ="students/*" />
</body>
</html>
</xsl:template>
<xsl:template match ="students/*" >
<xsl:apply-templates select = "rollno" />
<xsl:apply-templates select = "studentname" />
<xsl:apply-templates select = "coursename" />
<xsl:apply-templates select = "totalmarks" />
<xsl:apply-templates select = "academicyear" />
<br />
</xsl:template>
<xsl:template match = "rollno">
<span style ="font-size =22px;">
<xsl:value-of select ="." />
</span>
<br />
</xsl:template>
<xsl:template match ="studentname">
Student Name:<span style ="color:blue;">
<xsl:value-of select = "." />
</span>
<br />
</xsl:template>
<xsl:template match ="coursename">
Course Name:<span style ="color:green;">
<xsl:value-of select = "." />
</span>
<br />
</xsl:template>
<xsl:template match ="totalmarks">
Total marks:<span style ="color:gray;">
<xsl:value-of select = "." />
</span>
<br />
</xsl:template>
<xsl:template match ="academicyear">
Academic year:<span style ="color:red;">
<xsl:value-of select = "." />
</span>
<br />
</xsl:template>
</xsl:stylesheet>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。