以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  [求助]为什么这个xsl这样写不可以,谁能看下,谢谢了  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=62311)


--  作者:a309303973
--  发布时间:5/7/2008 9:58:00 PM

--  [求助]为什么这个xsl这样写不可以,谁能看下,谢谢了
用相应的XSLT脚本,使其能最终将输入XML文档转换成XSL-FO文档,再用FOP转换成PDF文件。
XSL文件内容如下:
<?xml version="1.0"?>
<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:fo="http://www.w3.org/1999/XSL/Format"
   version="1.0">

<xsl:output method="xml" indent="yes"/>


<fo:table table-layout="fixed">
  <table-column column-width="150pt"/>
  <table-column column-width="150pt"/>
  <table-column column-width="150pt"/>
  <table-column column-width="150pt"/>
  <table-column column-width="150pt"/>
  <table-column column-width="150pt"/>
  <table-column column-width="150pt"/>
      <fo:table-row>
        <fo:table-cell>
          <fo:block>NO.</fo:block>
        </fo:table-cell>
        <fo:table-cell>
          <fo:block>name</fo:block>
        </fo:table-cell>
        <fo:table-cell>
          <fo:block>population(people)</fo:block>
        </fo:table-cell>
        <fo:table-cell>
          <fo:block>captial</fo:block>
        </fo:table-cell>
        <fo:table-cell>
          <fo:block>bird</fo:block>
        </fo:table-cell>
        <fo:table-cell>
          <fo:block>flower</fo:block>
        </fo:table-cell>
        <fo:table-cell>
          <fo:block>area</fo:block>
        </fo:table-cell>
      </fo:table-row>
      <xsl:for-each select="//states/state">
        <fo:table-row>
          <fo:table-cell>
            <fo:block><xsl:value-of select="position()"></xsl:value-of></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:value-of select="name"></xsl:value-of></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:value-of select="population"></xsl:value-of></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:value-of select="capital"></xsl:value-of></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:value-of select="bird"/></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:value-of select="flower"/></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:value-of select="area"/></fo:block>
          </fo:table-cell>
        </fo:table-row>
       </xsl:for-each>
      
</fo:table>

</xsl:stylesheet>
XML内容如下:
<?xml version="1.0" encoding ="UTF-8"?>
<?xml-stylesheet type="application/xml"
             href="ass04.xsl"?>
<states>

    <state>
        <name>California</name>
        <population units="people">33871648</population><!--2000 census-->
        <capital>Sacramento</capital>
        <bird>Quail</bird>
        <flower>Golden Poppy</flower>
        <area units="square miles">155959</area>
    </state>

    <state>
        <name>Massachusetts</name>
        <population units="people">6349097</population><!--2000 census-->
        <capital>Boston</capital>
        <bird>Chickadee</bird>
        <flower>Mayflower</flower>
        <area units="square miles">7840</area>
    </state>

    <state>
        <name>New York</name>
        <population units="people">18976457</population><!--2000 census-->
        <capital>Albany</capital>
        <bird>Bluebird</bird>
        <flower>Rose</flower>
        <area units="square miles">47214</area>
    </state>

</states>


--  作者:gu_xiaorou
--  发布时间:5/8/2008 8:39:00 AM

--  
???有点不明白文的什么,不过fo的命令必须得有fo:root这个命令开始吧。。。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
62.500ms