以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  关于xsl:apply-templates  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=52541)


--  作者:rgbtdkjcel
--  发布时间:9/11/2007 9:44:00 PM

--  关于xsl:apply-templates
在xsl文件中使用了apply-templates元素后。。原来的xml文件什么都不显示呢??急!!


如何解决呢??


<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="1.xsl"?>
  <context>
<strong>middle</strong>
    </context>

此为xsl文件

<?xml version='1.0' encoding="gb2312" ?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/TR/WD-xsl" >
<xsl:template match="/">
    <p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>


--  作者:hexun831012
--  发布时间:9/12/2007 10:00:00 AM

--  
命名空间!!!

--  作者:txnnh
--  发布时间:9/12/2007 1:33:00 PM

--  
<xsl:apply-templates/> 但没有template 呀
--  作者:hexun831012
--  发布时间:9/13/2007 9:57:00 AM

--  
如果没有match属性,那么<xsl:apply-templates/>将匹配所有当前所有子元素,相当于<xsl:apply-templates match="*"/>
--  作者:791019wlk
--  发布时间:9/14/2007 9:19:00 PM

--  
你的XSL只是做了match,并没有取值
--  作者:gogy
--  发布时间:9/15/2007 9:49:00 AM

--  
以下是引用hexun831012在2007-9-13 9:57:00的发言:
如果没有match属性,那么<xsl:apply-templates/>将匹配所有当前所有子元素,相当于<xsl:apply-templates match="*"/>


这种说法值得商榷。
首先来说,<xsl:apply-templates/>缺省的是select属性,不是match属性。
另外,In the absence of a select attribute, the xsl:apply-templates instruction processes all of the children of the current node, including text nodes.(摘自W3C.org)。所以缺省select属性,相当于<xsl:apply-templates select="node()"/>,或者更具体来说是<xsl:apply-templates select="child::node()"/>,而不是<xsl:apply-templates match="*"/>。
--  作者:luypmp
--  发布时间:9/15/2007 6:42:00 PM

--  
xmlns:xsl="http://www.w3.org/TR/WD-xsl是Internet Explorer5.0的XSL样式表声明的方式(来自XSL工作草稿)使用的是较早版本的msxml解析器,有些xslt,xpath语法不能识别,xmlns:xsl="http://www.w3.org/1999/XSL/Transform是W3C XSL推荐中的样式表声明标准方式,除非你要绑定到其他平台,一般用这个还是安全点!


--  作者:luypmp
--  发布时间:9/15/2007 6:44:00 PM

--  
楼主把xmlns:xsl="http://www.w3.org/TR/WD-xsl" 换成http://www.w3.org/1999/XSL/Transform就ok了
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms