xsl未应用于xml文件



我有一个简单的xml和xsl程序来打印表中的学生数据,这是我第一次使用xml。在运行程序时完成程序后,我不会得到表上的输出。起初,我认为我的代码可能有一些错误,但我在我的三个朋友ubuntu系统上尝试了相同的xml和xsl文件,它运行得很好。关于信息,我使用ubuntu 18,我所有的朋友都使用相同的。我在他们的系统上以同样的方式尝试了同样的代码,但仍然没有得到输出。有人能告诉我为什么会有这个问题吗。

这是我的xml文件(Student.xml(:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Student.xsl"?>
<studInfo>
<stud>
<name>ABC</name>
<dob>12/04/2020</dob>
<rno>REG001</rno>
<course>MCA</course>
</stud>
<stud>
<name>ABC</name>
<dob>12/04/2020</dob>
<rno>REG001</rno>
<course>MCA</course>
</stud>
<stud>
<name>ABC</name>
<dob>12/04/2020</dob>
<rno>REG001</rno>
<course>MCA</course>
</stud>
</studInfo>

这是我的xsl文件(Student.xsl(:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Student Details</title>
</head>
<body>
<center>
<table border="1">
<caption>Student Details</caption>
<tr>
<th>Name</th>
<th>Date of birth</th>
<th>Register No</th>
<th>Course</th>
</tr>
<xsl:for-each select="/studInfo/stud">
<tr>
<td>
<xsl:value-of select="name" />
</td>
<td>
<xsl:value-of select="dob" />
</td>
<td>
<xsl:value-of select="rno" />
</td>
<td>
<xsl:value-of select="course" />
</td>
</tr>
</xsl:for-each>
</table>
</center>
</body>
</html>
</xsl:template>
</xsl:transform>

我通过右键单击xml文件并选择用mozilla firefox打开的选项来运行我的xml文件。同样的方式也适用于我的朋友,但不适用于我

我在一条直线上得到我的输出,没有这样的表格:

ABC 12/04/2020 REG001 MCA ABC 12/04/2020 REG001 MCA ABC 12/04/2020 REG001 MCA

有人能帮我吗。请

我将xsltproc的结果管道传输到lynx(xsltproc Student.xsl Student.xml | lynx -stdin(中,并得到

CAPTION: Student Details
Name Date of birth Register No Course
ABC  12/04/2020    REG001      MCA
ABC  12/04/2020    REG001      MCA
ABC  12/04/2020    REG001      MCA

因此,即使是文本控制台浏览器lynx也显示了一个表结构。

最新更新