以文本方式查看主题

-  中文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=6844)


--  作者:yongchungu
--  发布时间:4/19/2004 11:38:00 AM

--  新手求助
xsl如下:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http"//www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table>
<tr>
<td>
名称
</td>
<td>
类型
</td>
</tr>
<xsl:apply-templates select="Info" />
</table>
</xsl:template>
<xsl:template match="Info">
<xsl:for-each select="detail">
<tr>
<td>
<xsl:value-of select="name">
</td>
<td>
<xsl:value-of select="type">
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


xml如下:
<?xml version="1.0" encoding="gb2312" >
<?xml-stylesheet type="text/xsl" href="1.xsl"?>
<Info xmlns="http://www.myproject.com/myservice">
<detail>
<name>
name1
</name>
<type>
type1
</type>
</detail>
<detail>
<name>
name2
</name>
<type>
type2
</type>
</detail>
</Info>

只能显示table的表头,具体内容信息显示不出来.但是如果把根元素info中的xmlns=""去掉,就可以显示所有的信息了.但是根元素info中的xmlns,在我的应用中,是不能去掉的.


请问如何解决?


--  作者:yongchungu
--  发布时间:4/19/2004 11:56:00 AM

--  
刚才有笔误.
xml和xsl分别如下:

<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="1.xsl"?>
<Info xmlns="http://www.my.com/myservice">
 <detail>
  <name>name1</name>
  <type>type1</type>
 </detail>
 <detail>
  <name>name2</name>
  <type>type2</type>
 </detail>
</Info>

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http//www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
 <table>
 <tr bgcolor="#eeeeee">
  <td>名称</td>
  <td>类型</td>
 </tr>
 <xsl:apply-templates select="Info" />
 </table>
</xsl:template>

<xsl:template match="Info">
 <xsl:for-each select="detail">
  <tr>
   <td><xsl:value-of select="name"/></td>
   <td><xsl:value-of select="type"/></td>
  </tr>
 </xsl:for-each>
</xsl:template>

</xsl:stylesheet>


--  作者:sam
--  发布时间:4/19/2004 12:01:00 PM

--  
xml:
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="1.xslt"?>
<Q:Info xmlns:Q="http://www.myproject.com/myservice">
<Q:detail>
<Q:name>
name1
</Q:name>
<Q:type>
type1
</Q:type>
</Q:detail>
<Q:detail>
<Q:name>
name2
</Q:name>
<Q:type>
type2
</Q:type>
</Q:detail>
</Q:Info>


xslt:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:Q="http://www.myproject.com/myservice">
<xsl:template match="/">
<table>
<tr>
<td>
名称
</td>
<td>
类型
</td>
</tr>
<xsl:apply-templates select="Q:Info" />
</table>
</xsl:template>
<xsl:template match="Q:Info">
<xsl:for-each select="Q:detail">
<tr>
<td>
<xsl:value-of select="Q:name"/>
</td>
<td>
<xsl:value-of select="Q:type"/>
</td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


--  作者:robert
--  发布时间:4/19/2004 1:44:00 PM

--  
这里你要明确一点,xmlns是xml保留字,具体用法是xmlns:perfix="uri",sam是正确用法
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
39.063ms