我有以下簡單的XSL樣式表:瀏覽器的行爲 - 從火狐IE/Chrome有什麼不同
<?xml version="1.0" encoding="windows-1252"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" version="1.0">
<xsl:output encoding="utf-8" method="html" />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
</xsl:text>
<html>
<head><title>hello world</title></head>
<body>
<p>hello world</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
當我使用它時,Internet Explorer 7和Safari 5.0.2都只是顯示的 「Hello World」 ,如預期。不過,Firefox 3.6.10顯示不同的東西:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
hello world
我猜,火狐走的是第一的xsl:text命令從字面上,而IE和Safari把它當作頁面的一部分。 IE和Safari是否正確渲染這個,或者是Firefox?
(我做了xsl:文本的東西,使MSXML庫輸出正確的標籤爲HTML5規範)
我剛剛試過Opera 10.62,顯然它根本不想顯示任何XSL。有做這項工作的祕密技巧嗎? – Colen 2010-10-05 16:23:41
@Colen:我有一箇舊的XML/XSLT驅動的跨瀏覽器網站[here](http://www.aranedabienesraices.com.ar)。隨意重複使用此代碼。 – 2010-10-05 16:40:09
非常感謝! – Colen 2010-10-05 19:20:16