以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  xsd模板规则是不是用错了,浏览xm文档时一片空白!l  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=10640)


--  作者:yangxch
--  发布时间:9/27/2004 3:05:00 PM

--  xsd模板规则是不是用错了,浏览xm文档时一片空白!l
xml文档

<?xml version="1.0" encoding="GB2312"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by yang (yang) -->
<?xml-stylesheet type="text/xsl" href="3-10.xsl"?>
<CD>
 <商品>
  <定购人信息>
   <姓名>里斯</姓名>
   <详细地址>
    <街道>清华大学25号</街道>
    <城市>北京</城市>
    <省>北京</省>
    <国家>中国</国家>
    <邮政编码>100084</邮政编码>
   </详细地址>
  </定购人信息>
  <备注 付款方式="现金" 订货日期="2000-12-07">请赶紧发货,即用!</备注>
 </商品>
 <商品>
  <定购人信息>
   <姓名>张三</姓名>
   <详细地址>
    <街道>南京路555#</街道>
    <城市>上海</城市>
    <省>上海</省>
    <国家>中国</国家>
    <邮政编码>210002</邮政编码>
   </详细地址>
  </定购人信息>
  <备注 付款方式="信用卡" 订货日期="2000-12-08">请在15天内寄到!</备注>
 </商品>
</CD>

xsl文档
<?xml version="1.0" encoding="GB2312"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by yang (yang) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!--根模板-->
 <xsl:template match="/">
  <html>
   <head>
    <title>订购信息</title>
   </head>
   <body>
    <xsl:apply-templates select="CD/商品/订购人信息"/>
   </body>
  </html>
 </xsl:template>
 <!--订购人信息-->
 <xsl:template match="订购人信息">
  <table border="1" cellpadding="0">
   <xsl:apply-templates select="姓名"/>
   <xsl:apply-templates select="详细地址"/>
   <tr/>
  </table>
 </xsl:template>
 <!--姓名模板-->
 <xsl:template match="姓名">
  <td>姓名</td>
  <td>
   <xsl:value-of select="."/>
  </td>
 </xsl:template>
 <!--地址模板-->
 <xsl:template match="详细地址">
  <table border="1" cellpadding="0">
   <xsl:apply-templates select="街道"/>
   <xsl:apply-templates select="城市"/>
   <xsl:apply-templates select="省|直辖市"/>
   <xsl:apply-templates select="国家"/>
   <xsl:apply-templates select="邮政编码"/>
  </table>
 </xsl:template>
 <!--街道模板-->
 <xsl:template match="街道">
  <td>街道</td>
  <td>
   <xsl:value-of select="."/>
  </td>
 </xsl:template>
 <!--城市模板-->
 <xsl:template match="城市">
  <td>城市</td>
  <td>
   <xsl:value-of select="."/>
  </td>
 </xsl:template>
 <!--省|直辖市模板-->
 <xsl:template match="省|直辖市">
  <td>省|直辖市</td>
  <td>
   <xsl:value-of select="."/>
  </td>
 </xsl:template>
 <!--国家模板-->
 <xsl:template match="国家">
  <td>国家</td>
  <td>
   <xsl:value-of select="."/>
  </td>
 </xsl:template>
 <!--邮政编码模板-->
 <xsl:template match="邮政编码">
  <td>邮政编码</td>
  <td>
   <xsl:value-of select="."/>
  </td>
 </xsl:template>
</xsl:stylesheet>

模板运用那儿出错了??



--  作者:doubleG
--  发布时间:9/28/2004 9:15:00 AM

--  
<body>
    <xsl:apply-templates select="CD/商品/订购人信息"/>
   </body>
——>
<body>
    <xsl:apply-templates select="CD/商品"/>
   </body>

--  作者:yangxch
--  发布时间:9/28/2004 3:01:00 PM

--  
运行出来了,但是不懂为社么,

apply-templates的select属性不应该和template的 match属性相同吗

<xsl:apply-templates select="街道"/>
<xsl:template match="街道">为社么可以?


--  作者:doubleG
--  发布时间:9/28/2004 3:04:00 PM

--  
apply-templates是指select的节点下的那些节点。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms