以文本方式查看主题

-  计算机科学论坛  (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=16047)


--  作者:suyure
--  发布时间:3/25/2005 5:29:00 PM

--  请哪位大侠帮我解释一下好吗?我试了一天还没弄懂。
xml文件如下
<?xml version="1.0" encoding="gb2312"?>
<?xml:stylesheet type="text/xsl" href="Info.xsl"?>
<Info xmlns="http://tempuri.org/Detail.xsd">
 <name>ysq</name>
 <sex>male</sex>
 <title>hhhhhhh</title>
 <docs>
                 <doc>
   <docName>how to java</docName>
   <location>who know</location>
  </doc>
  <doc>
   <docName>how to C#</docName>
   <location>anywhere</location>
  </doc>
 </docs>
</Info>
---------------------------------------------------------------------------------------------------------------
xsl文件如下,请问为什么我看不到table的??存在哪些认识错误?

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
  <html>
   <head>
    <title>just a test!</title>
   </head>
   <body>
    <xsl:apply-templates/>
   </body>
  </html>
 </xsl:template>
 <xsl:template match="Info">
  <table  border="1" cellpadding="0">
      <thead>    
  <th>姓名</th><xsl:apply-templates  select="name"/>
  <th>性别</th><xsl:apply-templates select="sex"/>
  <th>职称</th><xsl:apply-templates select="title"/>                     </thead>
  </table>
  <p/>
  <xsl:apply-templates select="docs"/>
 </xsl:template>
 <xsl:template match="name">
  <td><xsl:value-of /></td>
 </xsl:template>
 <xsl:template match="sex">
  <td><xsl:value-of /></td>
 </xsl:template>
 <xsl:template match="title">
 <td><xsl:value-of /></td>
 </xsl:template>
 <xsl:template match="docs">
    <p/>
  <b>已发表论文:</b>
  <xsl:apply-templates/>
 </xsl:template>
 <xsl:template match="doc">
  <b>
   <xsl:value-of select="docName"/>
  </b>
  <p/> 
   <b>
    <a href="{location}">论文下载</a>
   </b>    
 </xsl:template>
</xsl:stylesheet>


--  作者:suyure
--  发布时间:3/25/2005 6:09:00 PM

--  
我终于知道为什么了,是不是我用的名字空间不是微软的那套?
因为我改用它的那套
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/TR/WD-xsl"
    xmlns="http://www.w3.org/TR/REC-html40" >
就没问题了。汗啊
--  作者:suyure
--  发布时间:3/25/2005 6:33:00 PM

--  
真的是这样的原因吗?
--  作者:Qr
--  发布时间:3/25/2005 7:01:00 PM

--  
以下是引用suyure在2005-3-25 18:09:20的发言:
我终于知道为什么了,是不是我用的名字空间不是微软的那套?
因为我改用它的那套
<xsl:stylesheet
     xmlns:xsl="http://www.w3.org/TR/WD-xsl"
     xmlns="http://www.w3.org/TR/REC-html40" >
就没问题了。汗啊


这套和前面一套都是W3C的,只是版本的问题。具体到W3C去瞧瞧。

--  作者:suyure
--  发布时间:3/25/2005 9:20:00 PM

--  
我在教育网上外国网站是慢到发疯的。
但是我这里有个例子又行,什么原因呢?
xml文件如下
<?xml version="1.0" encoding="GB2312"?>

<?xml:stylesheet type="text/xsl" href="cd_catalog.xsl"?>

<CATALOG>

   <CD>

       <TITLE>Empire Burlesque</TITLE>

       <ARTIST>Bob Dylan</ARTIST>

       <COUNTRY>USA</COUNTRY>

       <COMPANY>Columbia</COMPANY>

       <PRICE>10.90</PRICE>

       <YEAR>1985</YEAR>

   </CD>

   <CD>

       <TITLE>喀什噶尔胡杨</TITLE>

       <ARTIST>刀郎</ARTIST>

       <COUNTRY>China</COUNTRY>

       <COMPANY>先之唱片</COMPANY>

       <PRICE>20.60</PRICE>

       <YEAR>2004</YEAR>

   </CD>

   <CD>

       <TITLE>敦煌(特别版)</TITLE>

       <ARTIST>女子十二乐坊</ARTIST>

       <COUNTRY>China</COUNTRY>

       <COMPANY>百代唱片</COMPANY>

       <PRICE>25.60</PRICE>

       <YEAR>2005</YEAR>

   </CD>

</CATALOG>

----------------------------------------------------------------------------------------------------------------------------
xsl文件如下
<?xml version="1.0" encoding="GB2312"?>

<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="/">

       <html>

          <body>

             <table border="2" bgcolor="yellow">

                 <tr>

                    <th>Title</th>

                    <th>Artist</th>

                 </tr>

                 <xsl:for-each select="CATALOG/CD">

                    <tr>

                        <td>

                           <xsl:value-of select="TITLE"/>

                       </td>

                       <td>

                           <xsl:value-of select="ARTIST"/>

                       </td>

                    </tr>

                 </xsl:for-each>

             </table>

          </body>

       </html>

   </xsl:template>

</xsl:stylesheet>

问题是<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
为什么在这个例子里没问题,在前面的例子中使用就有问题????


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