-- 作者: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>
|