我遇到了本地存储的.xml和.xls文件的问题。
我的xml文件是:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="statement.xsl" ?>
<STATEMENT_3>
<SENTENCE>
<MENTAL>In my mind there are things I remember and things that are confused </MENTAL>
</SENTENCE>
<SENTENCE>
<MATTERIAL>I saw him near the basketball court </MATTERIAL>
</SENTENCE>
<SENTENCE>
<MATTERIAL> I saw him at my front door </MATTERIAL>
</SENTENCE>
</STATEMENT_3>
我的.xsl文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<html xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body style="font-family:Arial;font-size:13pt;background-color:#E8E09C">
<xsl:for-each select="STATEMENT_3/SENTENCE">
<div style="background-color:blue;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="MENTAL"/> - </span>
</div>
<div style="background-color:green;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="MATTERIAL"/> - </span>
</div>
</xls:for-each>
</body>
</html>
</xsl:stylesheet>
Chrome提供空白页面,Firefox表示存在错误:
</xls:for-each>
我已经google了很多但是找不到任何可行的解决方案。
答案 0 :(得分:0)
</xls:for-each>
需要:
</xsl:for-each>
此外,样式表必须至少包含一个模板。尝试类似:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body style="font-family:Arial;font-size:13pt;background-color:#E8E09C">
<xsl:for-each select="STATEMENT_3/SENTENCE">
<div style="background-color:blue;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="MENTAL"/> - </span>
</div>
<div style="background-color:green;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="MATTERIAL"/> - </span>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
有关Chrome中XSLT的问题,请参阅(例如): Testing xslt code using your browser