0
我正在使用XSLT將IE11中的XML文件顯示爲HTML。 我看到的不是HTML,而是純文本。 這兩個文件都保存在同一個文件夾中。瀏覽器爲XML/XSLT顯示純文本而非HTML
我比較/在W3School
兩個文件是基於下面我XSL文件關閉的例子。
RuleDefinitions.xml:
<?xml-stylesheet type= "html/xsl" href= "RuleDescriptions.xsl"?>
<rules>
<rule>
<term>FCFPriRegExp</term>
<title>ClassNameRegexp</title>
<description>This rule specifies the naming conventions for private final
class fields. The definition is done with a regexp (Regular
expression)</description>
</rule>
<rule>
<term>RegExpPrefixForMethodReturingBoolean</term>
<title>MethodReturningBoolean</title>
<description>This rule specifies the regexp for a method returning a
boolean value. In general a method returning a boolen is phrased like a
question and should normally comply to isEmpty(), hasMoreElements(),
areBlack(), ... Here you can specify a regexp which describes the name
for methods returning a boolean value.</description>
</rule>
RuleDefinitions.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xlmns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html xlns="http://www.w3.org/1999/xhtml">
<head>
<title>Java Code Standard Rules</title>
</head>
<body>
<table border="1">
<tr bgcolor="#9acd32">
<th>Term</th>
<th>Title</th>
<th>Description</th>
</tr>
<xsl:for-each select="rules/rule">
<tr>
<td><xsl:value-of select="term"/></td>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="description"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
並且xml中的href是錯誤的 – wero
好點!我已經修改了我的答案。非常感謝您指出這一點! –
謝謝,@TimC和wero, 文件名是拼寫錯誤,但代碼是複製粘貼的,雖然我沒有包含整個1000+行XML文件,所以「」就在那裏。 我很感激你的幫助。 – Zaxxon