以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  新手求教?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=6804)


--  作者:yongchungu
--  发布时间:4/17/2004 12:31:00 AM

--  新手求教?
我是个xsl新手。碰到如下问题,不知如何解决。

2篇xml文档如下:
<?xml version=1.0?>
<response xmlns="http://www.myproject.com/qt/queryservice">
<cell>
10
</cell>
</response>

<?xml version=1.0?>
<response>
<cell>
10
</cell>
</response>

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="response">
<xsl:for-each select="cell">
<xsl:value-of select=".">
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

第一篇xml文档不能按格式显示,第二篇就可以。唯一区别就是跟元素有一个xmlns,但是在我们的应用中,这个又是必需的。请问如何解决?


--  作者:KAI
--  发布时间:4/17/2004 2:15:00 AM

--  
和xmlns没关系,是你xsl写错了
XMl
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="1.xsl" ?>
<response xmlns="http://www.myproject.com/qt/queryservice">
<cell>
10
</cell>
</response>
XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/response">
 <xsl:apply-templates select="/response/cell"/>
</xsl:template>
<xsl:template match="cell">
 <xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,535.156ms