读书人

xsl的一个有关问题

发布时间: 2012-05-20 16:03:12 作者: rapoo

xsl的一个问题
求解:为什么在IE上运行得不到xsl想要设置的结果


<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="icecream.xsl"?>
<icecream_shop>
<name>西直门全全冰激凌专营店</name>
<icecream>
<货号>0389357</货号>
<品名>吃了必吐</品名>
<价格>75.00</价格>
<描述页 网址="http://www.icecream.com/ouou.html">详细了解请到这里</描述页>
</icecream>
<icecream>
<货号>9378788</货号>
<品名>吐了必吃</品名>
<价格>45.89</价格>
<描述页 网址="http://www.icecream.com/etet.html">详细了解请到这里</描述页>
</icecream>
</icecream_shop>

icecream.xsl文件如下:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head><title>结果</title></head>
<body>
<div align="center"><p>冰激凌</p></div>
<div align="center"><p>
<xsl:value-of select="*/name"/>
</p></div>
<xsl:apply-templates select="icecream_shop"/>
</body>
</html>
</xsl:template>

<xsl:template match="icecream_shop">
<p align="center">
<table border="1">
<tr>
<td>货号</td>
<td>品名</td>
<td>价格</td>
<td>描述页</td>
</tr>
<xsl:for-each select="icecream">
<tr>
<td><xsl:value-of select="货号"/></td>
<td><xsl:value-of select="品号"/></td>
<td><xsl:value-of select="价格"/></td>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="描述页/@网址"/>
</xsl:attribute>
<xsl:value-of select="描述页"></xsl:value-of>
</a>
</td>
</tr>
</xsl:for-each>
</table>
</p>
</xsl:template>
</xsl:stylesheet>

显示结果如下:

西直门全全冰激凌专营店 0389357 吃了必吐 75.00 详细了解请到这里 9378788 吐了必吃 45.89 详细了解请到这里

就是原样输出,得不到xsl设置的结果,我猜是不是xmln="http://www.w3.org/TR/REC-html40"已经换地址了啊

[解决办法]
用<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

XML code
<?xml version="1.0" encoding="gb2312"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">    <xsl:template match="/">        <html>            <head>                <title>结果</title>            </head>            <body>                <div align="center">                    <p>冰激凌</p>                </div>                <div align="center">                    <p>                        <xsl:value-of select="*/name"/>                    </p>                </div>                <xsl:apply-templates select="icecream_shop"/>            </body>        </html>    </xsl:template>    <xsl:template match="icecream_shop">        <p align="center">            <table border="1">                <tr>                    <td>货号</td>                    <td>品名</td>                    <td>价格</td>                    <td>描述页</td>                </tr>                <xsl:for-each select="icecream">                    <tr>                        <td>                            <xsl:value-of select="货号"/>                        </td>                        <td>                            <xsl:value-of select="品号"/>                        </td>                        <td>                            <xsl:value-of select="价格"/>                        </td>                        <td>                            <a>                                <xsl:attribute name="href"><xsl:value-of select="描述页/@网址"/></xsl:attribute>                                <xsl:value-of select="描述页"/>                            </a>                        </td>                    </tr>                </xsl:for-each>            </table>        </p>    </xsl:template></xsl:stylesheet> 

读书人网 >XML SOAP

热点推荐