我正在使用 XSLT 1.0 将 XML 转换为 HTML,但是我得到了不想要的输出。为什么我的评论消息中出现“data.flow2”
XML 文件:
<?xml version="1.0" encoding="utf-8" ?>
<CommentsList>
<Comment>
<CommentBy>data.flow2</CommentBy>
<CommentMsg>Set Under Study</CommentMsg>
</Comment>
<Comment>
<CommentBy>data.flow2</CommentBy>
<CommentMsg>True Files</CommentMsg>
</Comment>
<Comment>
<CommentBy>data.flow2</CommentBy>
<CommentMsg>
<![CDATA[<a href='http://eservices.saudieng.sa/Attachments/DataFlowReports/ce2cd49ac33e45edb8902c7d074d 908a.pdf'>Download the Report</a>]]> </CommentMsg>
</Comment>
</CommentsList>
这是 xslt:
<?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/>
</body>
</html>
</xsl:template>
<xsl:template match="CommentsList">
<table border="1">
<tr style="background-color:lightblue">
<td>Comment By</td>
<td>Comment Msg</td>
<td>Comment Date</td>
</tr>
<xsl:for-each select="/CommentsList/Comment">
<tr>
<td>
<xsl:value-of select="CommentBy"/>
</td>
<xsl:choose>
<xsl:when test="/CommentsList/Comment[3]/CommentMsg">
<td>
<CommentMsg>
<xsl:copy-of select="@*"/>
<xsl:value-of select="." disable-output-escaping="yes"/>
</CommentMsg>
</td>
</xsl:when>
<xsl:otherwise>
<td>
<xsl:apply-templates select="."/>
<xsl:value-of select="text()"/>
</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
评论消息的输出是这样的:
data.flow2 [评论消息文本]
为什么我只收到评论消息文本?
提前致谢 :)