XML文件包含帐户和帐户列表(包含ID和AccountDescription)。 在下面的例子中,有2个帐户。如何显示所有XSL元素?
<?xml version="1.0"?>
<Accounts>
<Account>
<ID>5</ID>
<AccountDescription>Account Description 5</AccountDescription>
</Account>
<Account>
<ID>8</ID>
<AccountDescription>Account Description 8</AccountDescription>
</Account>
</Accounts>
使用下面的XSL,它会创建2个页面的PDF文件,每一页都有标题ID和AccountDescription,但它下面没有数据/内容,如:
在页面1:
ID AccountDescription
在第2页:
ID AccountDescription
我想显示这样的数据:
ID AccountDescription
5帐户说明5
8帐户说明8
我该怎么做?谢谢。
这是我目前的XSL:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="Accounts">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master
master-name="main"
margin-top="0px"
margin-bottom="0px"
margin-left="18px"
margin-right="18px">
<fo:region-body margin-top="0.75in" margin-bottom="2in" margin-left="18px" margin-right="18px"/>
<fo:region-before extent="0.75in"/>
<fo:region-after extent="1.5in"/>
<fo:region-end extent="75px"/>
</fo:simple-page-master>
</fo:layout-master-set>
<xsl:apply-templates select="Account"/>
</fo:root>
</xsl:template>
<xsl:template match="Account">
<fo:page-sequence master-reference="main">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="10pt">
<fo:table-column column-width="15mm"/>
<fo:table-column column-width="55mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell >
<fo:block text-align="right"><xsl:value-of select="ID"/></fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block text-align="right"><xsl:value-of select="AccountDescription"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</xsl:template>
</xsl:stylesheet>
你想申请,模板/匹配'AccountRow',但该元素不会在你的示例XML存在。这是你的样式表的问题还是你的样本问题? –
是的,你是对的。我编辑了我原来的帖子,所以现在我不会调用。相反,我做了。 有了这个,我看到的数据,但每个数据显示在不同的页面上,即:Page 1我有5 - 帐户说明5,并在第2页我有8 - 帐户说明8.如何显示所有数据同一页?谢谢。 –
faujong