新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → [求助]请问关于xsl:template 的嵌套问题(含表格嵌套)[已解决] 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 5457 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [求助]请问关于xsl:template 的嵌套问题(含表格嵌套)[已解决] 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     isay 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:3
      积分:74
      门派:XML.ORG.CN
      注册:2005/10/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给isay发送一个短消息 把isay加入好友 查看isay的个人资料 搜索isay在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看isay的博客楼主
    发贴心情 [求助]请问关于xsl:template 的嵌套问题(含表格嵌套)[已解决]

    我(新手)有一xml文档。想用 xsl 将它格式化输出。
    有点类似于 stylus studio 2007 中 xml 的网格形式。
    请问我的 xsl 文档应该怎么写 ? (我写的xsl在后面)
    (我写的怎么也不显示表格里嵌套的表格内容。就有表头而已)
    xml:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="FileCollection.xsl"?>
    <DirectioryXmlModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <hasChildDirectiory>true</hasChildDirectiory>
      <hasFile>true</hasFile>
      <DirectoryPath>F:\MP3</DirectoryPath>
      <ChildDirectioryCount>72</ChildDirectioryCount>
      <ChildFileCount>4</ChildFileCount>
      <directorys>
        <DirectioryXmlModel>
          <Name>Nightwish</Name>
          <hasChildDirectiory>true</hasChildDirectiory>
          <hasFile>true</hasFile>
          <DirectoryPath>F:\MP3\</DirectoryPath>
          <ChildDirectioryCount>2</ChildDirectioryCount>
          <ChildFileCount>1</ChildFileCount>
          <directorys>
            <DirectioryXmlModel>
              <Name>Wishmaster</Name>
              <hasChildDirectiory>false</hasChildDirectiory>
              <hasFile>true</hasFile>
              <DirectoryPath>F:\MP3\Nightwish</DirectoryPath>
              <ChildDirectioryCount>0</ChildDirectioryCount>
              <ChildFileCount>16</ChildFileCount>
              <directorys />
              <files>
                <FileXmlModel>
                  <FileExtentsion>.wma</FileExtentsion>
                  <FileSize>6904654</FileSize>
                  <FileName>01 She Is My Sin.wma</FileName>
                  <FilePath>F:\MP3\Nightwish\Wishmaster</FilePath>
                </FileXmlModel>
              </files>
            </DirectioryXmlModel>
            <DirectioryXmlModel>
              <Name>Highest Hopes (The Best Of Nightwish-+DVD) [UK] Disc 1</Name>
              <hasChildDirectiory>false</hasChildDirectiory>
              <hasFile>true</hasFile>
              <DirectoryPath>F:\MP3\Nightwish</DirectoryPath>
              <ChildDirectioryCount>0</ChildDirectioryCount>
              <ChildFileCount>24</ChildFileCount>
              <directorys />
              <files>
                <FileXmlModel>
                  <FileExtentsion>.jpg</FileExtentsion>
                  <FileSize>10842</FileSize>
                  <FileName>AlbumArt_{69D655A1-12B9-4FD5-84C8-5C88EA5E154D}_Large.jpg</FileName>
                  <FilePath>F:\MP3\Nightwish\Highest Hopes (The Best Of Nightwish-+DVD) [UK] Disc 1</FilePath>
                </FileXmlModel>
              </files>
            </DirectioryXmlModel>
          </directorys>
          <files>
            <FileXmlModel>
              <FileExtentsion>.ini</FileExtentsion>
              <FileSize>322</FileSize>
              <FileName>desktop.ini</FileName>
              <FilePath>F:\MP3\Nightwish</FilePath>
            </FileXmlModel>
          </files>
        </DirectioryXmlModel>
       </directorys>
       <files>
        <FileXmlModel>
          <FileExtentsion>.MP3</FileExtentsion>
          <FileSize>1396950</FileSize>
          <FileName>test.MP3</FileName>
          <FilePath>F:\MP3\</FilePath>
        </FileXmlModel>
       </files>
    </DirectioryXmlModel>
    -------------------------------------------------------------------
    xsl :

    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
     <html>
     <body>
     <table border="1" >
      <tr>
      <td>路径</td>
      <td>有否有子目录</td>
      <td>是否有文件</td>
      <td>子目录数</td>
      <td>子文件数</td>
      </tr>
      <tr>
       <td>
        <xsl:value-of select="DirectioryXmlModel/DirectoryPath" />
       </td>
       <td>
        <xsl:value-of select="DirectioryXmlModel/hasChildDirectiory" />
       </td>
       <td>
        <xsl:value-of select="DirectioryXmlModel/hasFile" />
       </td>
       <td>
        <xsl:value-of select="DirectioryXmlModel/ChildDirectioryCount" />
       </td>
       <td>
        <xsl:value-of select="DirectioryXmlModel/ChildFileCount" />
       </td>
      </tr>
     </table>
      <table border="1">
       <xsl:apply-templates select="DirectioryXmlModel/directorys"/>
       <xsl:apply-templates select="DirectioryXmlModel/files" />
      </table>
     </body>
     </html>
    </xsl:template>

    <xsl:template match="directorys" name="dirTp">
    <table border="1">
      <tr>
      <td>目录名</td>
      <td>路径</td>
      <td>有否有子目录</td>
      <td>是否有文件</td>
      <td>子目录数</td>
      <td>子文件数</td>
      <td>目录</td>
      <td>文件</td>
      </tr>
      <xsl:for-each select="DirectioryXmlModel">
       <tr>
       <td>
        <xsl:value-of select="Name" />
       </td>
       <td>
        <xsl:value-of select="DirectoryPath" />
       </td>
       <td>
        <xsl:value-of select="hasChildDirectiory" />
       </td>
       <td>
        <xsl:value-of select="hasFile" />
       </td>
       <td>
        <xsl:value-of select="ChildDirectioryCount" />
       </td>
       <td>
        <xsl:value-of select="ChildFileCount" />
       </td>
       <td>
         <xsl:call-template name="dirTp">
          <xsl:with-param name="directorypath" select="self::DirectioryXmlModel/directorys" />
         </xsl:call-template>
       </td>
       <td>
        <xsl:call-template name="fileTp">
         <xsl:with-param name="filepath" select="self::DirectioryXmlModel/files" />
        </xsl:call-template>
       </td>
       </tr>
      </xsl:for-each>
      </table>
    </xsl:template>

    <xsl:template match="files" name="fileTp">
    <table border="1">
      <tr>
      <td>文件名</td>
      <td>扩展名</td>
      <td>文件大小(B)</td>
      <td>路径</td>
      </tr>
     <xsl:for-each select="FileXmlModel">
      <tr>
      <td>
       <xsl:value-of select="FileName" />
      </td>
      <td>
       <xsl:value-of select="FileExtentsion" />
      </td>
      <td>
       <xsl:value-of select="FileSize" />
      </td>
      <td>
       <xsl:value-of select="FilePath" />
      </td>
      </tr>
     </xsl:for-each>
     </table>
    </xsl:template>
    </xsl:stylesheet>


    [此贴子已经被作者于2007-5-23 12:39:42编辑过]

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/5/20 22:44:00
     
     hexun831012 帅哥哟,离线,有人找我吗?天秤座1983-10-12
      
      
      威望:1
      等级:研二(Pi-Calculus看得一头雾水)(版主)
      文章:800
      积分:5114
      门派:XML.ORG.CN
      注册:2006/12/8

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给hexun831012发送一个短消息 把hexun831012加入好友 查看hexun831012的个人资料 搜索hexun831012在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看hexun831012的博客2
    发贴心情 
    用xsl:apply-templates而不是xsl:call-template
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/5/22 9:20:00
     
     isay 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:3
      积分:74
      门派:XML.ORG.CN
      注册:2005/10/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给isay发送一个短消息 把isay加入好友 查看isay的个人资料 搜索isay在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看isay的博客3
    发贴心情 
    拜谢!

    搞掂了~

    郁闷了好多天。

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/5/22 18:21:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/8/15 14:47:50

    本主题贴数3,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    78.125ms