この奇妙な問題が発生しました。XSLがxmlで機能していません。これは私のxmlおよびxslコードです。
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xsl-stylesheet type= "text/xsl" href= "w3c.xsl"?>
<catalog>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
<cd>
<title>Eros</title>
<artist>Eros Ramazzotti</artist>
<country>EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
<cd>
<title>Romanza</title>
<artist>Andrea Bocelli</artist>
<country>EU</country>
<company>Polydor</company>
<price>10.80</price>
<year>1996</year>
</cd>
</catalog>
これは私のxslです:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
ノート:
私はこのコードをW3Cから取得したので、機能しています。グーグルで検索しましたが、機能するソリューションが見つかりませんでした。FirefoxとChromeを使用しましたが、いずれも機能しません。テストしました。リモートサーバーも機能しません。「このXMLファイルにはスタイル情報が関連付けられていないようです。ドキュメントツリーを以下に示します。」というエラーが表示されます。同じエラーが発生します。フルパスからファイル名だけへの可能なリンク。また、-allow-file-access-from-filesを使用してchromeを試しましたが、機能しません。これを修正するのを手伝ってください。