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

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → 求助,如何将空的信息也显示出来 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2878 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 求助,如何将空的信息也显示出来 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     cheng_fy 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:5
      积分:72
      门派:XML.ORG.CN
      注册:2004/6/5

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cheng_fy发送一个短消息 把cheng_fy加入好友 查看cheng_fy的个人资料 搜索cheng_fy在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cheng_fy的博客楼主
    发贴心情 求助,如何将空的信息也显示出来

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="maxtest.xsl"?>
    <BAPLIE>
     <SG5>
      <C1>
       <D1>7</D1>
       <D2>SEVENTH</D2>
      </C1>
     </SG5>
     <SG5>
      <C1>
       <D1>1</D1>
       <D2>FIRST</D2>
      </C1>
     </SG5>
     <SG5>
      <C1>
       <D1>3</D1>
       <D2>THIRD</D2>
      </C1>
     </SG5>
     <SG5>
      <C1>
       <D1>4</D1>
       <D2>FOURTH</D2>
      </C1>
     </SG5>
    </BAPLIE>
    我写的样式表:
    <?xml version="1.0" encoding="UTF-8"?>
    <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>
         <tr>
         <xsl:for-each select="BAPLIE/SG5">
          <xsl:if test="C1/D1='1'">
           <td>
           <xsl:value-of select="C1/D2"/>
           </td>
          </xsl:if>
         </xsl:for-each>
         <xsl:for-each select="BAPLIE/SG5">
          <xsl:if test="C1/D1='2'">
           <td>
           <xsl:value-of select="C1/D2"/>
           </td>
          </xsl:if>
         </xsl:for-each>
         <xsl:for-each select="BAPLIE/SG5">
          <xsl:if test="C1/D1='3'">
           <td>
           <xsl:value-of select="C1/D2"/>
           </td>
          </xsl:if>
         </xsl:for-each>
         </tr>
        </table>
       </BODY>
      </HTML>
     </xsl:template>
    </xsl:stylesheet>
    但D1=2无法显示,我要的结果是:
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>FIRST</td>
        <td>&nbsp;</td>
        <td>THIRD</td>
        <td>FOURTH</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>SEVENTH</td>
      </tr>
    </table>

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/6/7 12:21:00
     
     cheng_fy 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:5
      积分:72
      门派:XML.ORG.CN
      注册:2004/6/5

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cheng_fy发送一个短消息 把cheng_fy加入好友 查看cheng_fy的个人资料 搜索cheng_fy在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cheng_fy的博客2
    发贴心情 
    各位兄弟,谁能帮我解决上面的问题,只要能得到表格所示的结果就行,但注意:SG5的数目是不定的。
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/6/8 12:06:00
     
     sam 帅哥哟,离线,有人找我吗?
      
      
      头衔:日夜灌水W3C
      等级:大三暑假(ITELS考了7分!)
      文章:198
      积分:969
      门派:XML.ORG.CN
      注册:2004/3/24

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给sam发送一个短消息 把sam加入好友 查看sam的个人资料 搜索sam在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问sam的主页 引用回复这个贴子 回复这个贴子 查看sam的博客3
    发贴心情 
    比较烦,不知道是否符合要求?

    <?xml version="1.0" encoding="GB2312"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
      <html>
       <head/>
       <body>
        <table border="3">
         <tr>
          <xsl:for-each select="//SG5">
           <xsl:sort data-type="number" order="ascending" select="C1/D1"/>
           <xsl:if test="position() &lt; number(C1/D1)">
            <xsl:variable name="xxx">
             <xsl:call-template name="before">
              <xsl:with-param name="pos" select="position()"/>
             </xsl:call-template>
            </xsl:variable>
            <xsl:call-template name="fill">
             <xsl:with-param name="num" select="number(C1/D1) - $xxx"/>
            </xsl:call-template>
           </xsl:if>
           <td>
            <xsl:value-of select="C1/D2"/>
           </td>
          </xsl:for-each>
         </tr>
        </table>
       </body>
      </html>
     </xsl:template>
     <xsl:template name="fill">
      <xsl:param name="num" select="1"/>
      <xsl:if test="$num &gt; 1">
       <td>space</td>
       <xsl:variable name="temp" select="$num - 1"/>
       <xsl:call-template name="fill">
        <xsl:with-param name="num" select="$temp"/>
       </xsl:call-template>
      </xsl:if>
     </xsl:template>
     <xsl:template name="before">
      <xsl:param name="pos" select="1"/>
      <xsl:for-each select="//SG5">
       <xsl:sort data-type="number" order="ascending" select="C1/D1"/>
       <xsl:if test="position() = $pos - 1">
        <xsl:value-of select="C1/D1"/>
       </xsl:if>
      </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>

    ----------------------------------------------
    http://www.xml.org.cn/uploadFace/3819_20044191991837196.gif^_^

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/6/8 14:00:00
     
     cheng_fy 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:5
      积分:72
      门派:XML.ORG.CN
      注册:2004/6/5

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cheng_fy发送一个短消息 把cheng_fy加入好友 查看cheng_fy的个人资料 搜索cheng_fy在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cheng_fy的博客4
    发贴心情 
    不行啊,space太多了,但还有要感谢sam,现在很少人象你这样热心了
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/6/12 14: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/7/29 12:10:29

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

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