xsl问题
show.xml:
<?xml version= "1.0 " encoding= "utf-8 "?>
<?xml-stylesheet type= "text/xsl " href= "show.xsl "?>
<root aa= "abc " >
</root>
show.xsl:
<?xml version= "1.0 " encoding= "utf-8 "?>
<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform ">
<xsl:template match= "/ ">
<xsl:value-of select= "root/@aa " />
</xsl:template>
</xsl:stylesheet>
用IE打开show.xml,显示 abc
没有问题.
如果把show.xml做一些小改动,在root节点上加一属性(命名空间),变为:
<?xml version= "1.0 " encoding= "utf-8 "?>
<?xml-stylesheet type= "text/xsl " href= "show.xsl "?>
<root aa= "abc " xmlns= "http://www.opentravel.org/OTA/2003/05 " >
</root>
就有问题了,用IE打开show.xml,显示为空白.
本人乃这方面的新手,望大虾指教.
[解决办法]
show.xsl:加个namespace
<?xml version= "1.0 " encoding= "utf-8 "?>
<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform " xmlns:alt= "http://www.opentravel.org/OTA/2003/05 ">
<xsl:template match= "/ ">
<xsl:value-of select= "alt:root/@aa " />
</xsl:template>
</xsl:stylesheet>
[解决办法]
<xsl:value-of select= "*[name()= 'root ']/@aa "/>