今天測試xsl格式化xml,結果在chrome中始終無法顯示,換了火狐,ie8都能正常顯示。
后來終於漫長的實踐,才得到了解決方法。
開始的時候用的是普通的文件系統來測試的,也就是說直接把xml和xsl放在同一個文件夾中 ,然后在瀏覽器中查看xml,火狐和ie都能夠正常顯示,但是chrome卻無法顯示,后來想,chrome這么高級的瀏覽器不可能不行。於是后來把文件夾放到了web服務器的目錄下,訪問,chrome顯示正確的頁面。
<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="tool.xsl"?><tool><field id="prodName"><value>HAMMER HG2606</value></field><field id="prodNo"><value>32456240</value></field><field id="price"><value>$30.00</value></field></tool>
上面的是xml,下面提供xsl
<?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><html><body><form method="post" action="edittool.asp"><h2>Tool Information (edit):</h2><table border="0"><xsl:for-each select="tool/field"><tr><td><xsl:value-of select="@id"/></td><td><input type="text"><xsl:attribute name="id"> <xsl:value-of select="@id" /> </xsl:attribute><xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute><xsl:attribute name="value"> <xsl:value-of select="value" /></xsl:attribute></input></td></tr></xsl:for-each></table><br /><input type="submit" id="btn_sub" name="btn_sub" value="Submit" /><input type="reset" id="btn_reset" name="btn_reset" value="Reset" /></form></body></html></xsl:template></xsl:stylesheet>