[英]xsl is not applying on xml file
我有一個簡單的 xml 和 xsl 程序來在表格中打印學生數據,這是我第一次使用 xml。 在運行程序時完成程序后,我沒有在桌子上看到 output。 一開始我以為我的代碼可能有一些錯誤,但我在我的三個朋友 ubuntu 系統上嘗試了相同的 xml 和 xsl 文件,並且運行良好。 有關信息,我正在使用 ubuntu 18,我所有的朋友都在使用相同的。 我以與我在他們的系統上相同的方式嘗試了相同的代碼,但我仍然沒有得到 output。 誰能告訴我為什么我會遇到這個問題。
這是我的 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 文件。 同樣的方式也適用於我的朋友,但不適用於我。
我將我的 output 放在一條直線上,而沒有這樣的表格:
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 也顯示了一個表結構。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.