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

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 计算机科学论坛XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → 求助,FO中的table使用 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2676 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 求助,FO中的table使用 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     xprogrammer 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:3
      积分:64
      门派:XML.ORG.CN
      注册:2005/8/27

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给xprogrammer发送一个短消息 把xprogrammer加入好友 查看xprogrammer的个人资料 搜索xprogrammer在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看xprogrammer的博客楼主
    发贴心情 求助,FO中的table使用

    FO中的table怎么用啊
    文档里只有关于table中间的使用
    但是它怎么放到page里去?

    下面的例子我想往pdf中输出一个表格,但是输出却什么都没有,怎么回事?

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
       <fo:layout-master-set>
        <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
         <fo:region-body margin="3cm"/>
         <fo:region-before extent="2cm"/>
         <fo:region-after extent="2cm"/>
         <fo:region-start extent="2cm"/>
         <fo:region-end extent="2cm"/>
        </fo:simple-page-master>
       </fo:layout-master-set>
       <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
         <fo:table-and-caption>
          <fo:table>
           <fo:table-column column-width="25mm"/>
           <fo:table-column column-width="25mm"/>
           <fo:table-header>
            <fo:table-row>
             <fo:table-cell>
              <fo:block font-weight="bold">Car</fo:block>
             </fo:table-cell>
             <fo:table-cell>
              <fo:block font-weight="bold">Price</fo:block>
             </fo:table-cell>
            </fo:table-row>
           </fo:table-header>
           <fo:table-body>
            <fo:table-row>
             <fo:table-cell>
              <fo:block>Volvo</fo:block>
             </fo:table-cell>
             <fo:table-cell>
              <fo:block>$50000</fo:block>
             </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
             <fo:table-cell>
              <fo:block>SAAB</fo:block>
             </fo:table-cell>
             <fo:table-cell>
              <fo:block>$48000</fo:block>
             </fo:table-cell>
            </fo:table-row>
           </fo:table-body>
          </fo:table>
         </fo:table-and-caption>
        </fo:flow>
       </fo:page-sequence>
      </fo:root>
     </xsl:template>
    </xsl:stylesheet>


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/8/27 17:03:00
     
     fanzhixin 帅哥哟,离线,有人找我吗?巨蟹座1980-7-3
      
      
      等级:大二(研究C++)
      文章:33
      积分:230
      门派:XML.ORG.CN
      注册:2005/4/28

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给fanzhixin发送一个短消息 把fanzhixin加入好友 查看fanzhixin的个人资料 搜索fanzhixin在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看fanzhixin的博客2
    发贴心情 
    xls-fo 文件本身就是一个格式化好了的xml文件,有点像html文件,不同的是它是输出在出版物,如pdf上的,因此你可以将它直接转pdf

    把这段代码保存成.fo 文件就可以直接转为pdf
      <?xml version="1.0" encoding="UTF-8"?>
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
       <fo:layout-master-set>
        <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
         <fo:region-body margin="3cm"/>
         <fo:region-before extent="2cm"/>
         <fo:region-after extent="2cm"/>
         <fo:region-start extent="2cm"/>
         <fo:region-end extent="2cm"/>
        </fo:simple-page-master>
       </fo:layout-master-set>
       <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
         <fo:table-and-caption>
          <fo:table>
           <fo:table-column column-width="25mm"/>
           <fo:table-column column-width="25mm"/>
           <fo:table-header>
            <fo:table-row>
             <fo:table-cell>
              <fo:block font-weight="bold">Car</fo:block>
             </fo:table-cell>
             <fo:table-cell>
              <fo:block font-weight="bold">Price</fo:block>
             </fo:table-cell>
            </fo:table-row>
           </fo:table-header>
           <fo:table-body>
            <fo:table-row>
             <fo:table-cell>
              <fo:block>Volvo</fo:block>
             </fo:table-cell>
             <fo:table-cell>
              <fo:block>$50000</fo:block>
             </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
             <fo:table-cell>
              <fo:block>SAAB</fo:block>
             </fo:table-cell>
             <fo:table-cell>
              <fo:block>$48000</fo:block>
             </fo:table-cell>
            </fo:table-row>
           </fo:table-body>
          </fo:table>
         </fo:table-and-caption>
        </fo:flow>
       </fo:page-sequence>
      </fo:root>


    xsl 文件是样式表文件,它需要xml 文件配合
    xml 文件 table.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <table>
      <header>
       <column>
        <cell>Car</cell>
       </column>
        <column>
        <cell>Priece</cell>
       </column>
      </header>
      <body>
        <row>
          <name>
          <cell>Volvo</cell>
          </name>
          <price>
          <cell>$50000</cell>
          </price>
        </row>
        <row>
          <name>
          <cell>SAAB</cell>
          </name>
          <price>
          <cell>$48000</cell>
          </price>
        </row>
      </body>
    </table>

    xsl 文件 table.xsl

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="table">
      <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
       <fo:layout-master-set>
        <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">
         <fo:region-body margin="3cm"/>
         <fo:region-before extent="2cm"/>
         <fo:region-after extent="2cm"/>
         <fo:region-start extent="2cm"/>
         <fo:region-end extent="2cm"/>
        </fo:simple-page-master>
       </fo:layout-master-set>
       <fo:page-sequence master-reference="A4">
        <fo:flow flow-name="xsl-region-body">
         <fo:table-and-caption>
          <fo:table>
           <fo:table-column column-width="25mm"/>
           <fo:table-column column-width="25mm"/>
           <fo:table-header>
                <fo:table-row>
                     <xsl:for-each select="header/column">     
                      <fo:table-cell>
                        <fo:block font-weight="bold"><xsl:value-of select="cell"/></fo:block>
                      </fo:table-cell>
                     </xsl:for-each>
                 </fo:table-row>
            </fo:table-header>
         <fo:table-body>
             <xsl:for-each select="body/row">
               <fo:table-row>              
                   <fo:table-cell>
                          <fo:block><xsl:value-of select="name"/></fo:block>
                      </fo:table-cell>
                      <fo:table-cell>
                          <fo:block><xsl:value-of select="price"/></fo:block>
                      </fo:table-cell>
                </fo:table-row>
              </xsl:for-each>
           </fo:table-body>
          </fo:table>
         </fo:table-and-caption>
        </fo:flow>
       </fo:page-sequence>
      </fo:root>
    </xsl:template>
    </xsl:stylesheet>

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

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

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