This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re:Re: Problems still with elements print first page only
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Re:Re: Problems still with elements print first page only
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Tue, 24 Jul 2001 10:30:08 +0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Tamre;
A tested xsl listing is included here to your listed problem.
It is modifing your original xsl and
based on Trevor and David's suggestions as following way;
1. Suggestions from Trevor Nash that apply xsl:copy-of and
variable rather doing call-template. So you will not worry about
the problem with print on different occasions.
There are two variables , $pagefoot and $pagehead are defined in
following
way.
1.1 For $pagefoot it is assigned to be global variable, since its
content
is only funtion of top element.
2.2 for $pagehead it is assigned inside of template as a local variable,
because its content is varied with the second level element of accoutInfo.
Therefore with-param has to be used to pass this local variable between
templates.
2 Suggestion from David suggestion, use template instead of for-each
element.
Hopefully it will be useful to you.
Cheers,
Sun-fu Yang,
sfyang@unisvr.net.tw
*** xsl list ***
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<!-- using variable to define a group of lines for printing -->
<!-- using copy-of to activate this variable , not value-of (it works only
for a single entry) -->
<xsl:variable name="rowsPerPage" select="8"/>
<xsl:variable name="pagefoot">
<xsl:call-template name="pagefoot"/>
</xsl:variable>
<xsl:variable name="title" select="//title"/>
<xsl:variable name="stmtPeriod" select="//stmPeriod"/>
<xsl:variable name="text" select="//text"/>
<xsl:template match="/">
<html>
<head>
<link rel="Stylesheet" href="statement.css" type="text/css"/>
</head>
<body>
<xsl:variable name="pagehead">
<xsl:apply-templates select="//accountInfo" mode="pagehead"/>
</xsl:variable>
<xsl:copy-of select="$pagehead"/>
<xsl:apply-templates select="//accountInfo" mode="pagetable">
<xsl:with-param name="pagehead" select="$pagehead"/>
</xsl:apply-templates>
<xsl:copy-of select="$pagefoot"/>
<!--<xsl:call-template name="pagefoot">
</xsl:call-template>-->
</body>
</html>
</xsl:template>
<xsl:template match="accountInfo" mode="pagehead">
<DIV style="position: relative; top:4px; width:4in;left:6in">
<xsl:value-of select="acctnum"/>
<span class="shiftright">
<xsl:value-of select="taxid"/>
</span>
<span class="shiftrightb">
<xsl:value-of select="$stmtPeriod"/>
</span>
</DIV>
<DIV style="position: relative; height:.75in; width:3in;left -2px;top:10px;
font-size: 8pt; border:2px solid pink;">
<xsl:value-of select="acctname"/>
<br/>
<xsl:value-of select="address1"/>
<xsl:value-of select="address2"/>
<br/>
<xsl:value-of select="city"/>
<xsl:value-of select="state"/>
<xsl:value-of select="zip"/>
</DIV>
<DIV style="position: relative; height:.5in; width:4in;left:
3in;top:-.5in;">
<h4>
<xsl:value-of select="$title"/></h4>
</DIV>
<DIV style="position: relative; top:2px; border:2px solid orange;">
<table>
<tr>
<th align="left" width="65px">DATE</th>
<th width="70px">LONG<br/>(Bought or<br/> Received)</th>
<th width="70px">SHORT<br/>(Sold or<br/> Delivered)</th>
<th align="left" width="225px">DESCRIPTION</th>
<th width="50px">PRICE/<br/>CODE</th>
<th align="right" width="160px">DEBIT</th>
<th align="right" width="160px">CREDIT</th>
<th align="right" width="180px">LEDGER<br/>BALANCE</th>
</tr>
</table>
</DIV>
<hr style="position: relative; top:7px;"/>
</xsl:template>
<xsl:template match="accountInfo" mode="pagetable">
<xsl:param name="pagehead"/>
<DIV style="position: relative; top:10px;">
<table id="table1">
<caption><xsl:value-of select="acctnum"/> 
<!--whitespace between elements-->
<xsl:value-of select="accttitle"/></caption>
<caption id="caption2">
<xsl:value-of select="$text"/> <xsl:value-of
select="format-number(transactions/@beginBal,'#,##0.00DB;#,##0.00CR')"/>
</caption>
<xsl:apply-templates select="transactions/transaction" mode="rowcount">
<xsl:with-param name="pagehead" select="$pagehead"/>
</xsl:apply-templates>
<!--/xsl:for-each--> <!--transactions/transaction-->
</table>
</DIV>
</xsl:template>
<xsl:template match="transaction" mode="rowcount">
<xsl:param name="pagehead"/>
<tr>
<td width="65px" align="left"><xsl:value-of select="date"/> </td>
<td width="70px"><xsl:value-of select="long"/> </td>
<td width="70px"><xsl:value-of select="short"/> </td>
<td width="225px"><xsl:value-of select="description"/> </td>
<td width="50px" align="center"><xsl:value-of
select="priceCode"/> </td>
<td width="160px" align="right">
<xsl:if test="substring(amount,1,1)!='-'">
<xsl:value-of
select="format-number(amount,'#,##0.00')"/> </xsl:if></td>
<td width="160px" align="right">
<xsl:if test="substring(amount,1,1)='-'">
<xsl:value-of
select="format-number(amount,'#,##0.00')"/> </xsl:if></td>
<td width="180px" align="right">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:value-of
select="format-number(amount + //@beginBal,'#,##0.00DB;#,##0.00CR')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="format-number(amount + sum(preceding-sibling::transaction/amount)+
//@beginBal,'#,##0.00DB;#,##0.00CR')"/> 
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
<xsl:if test="position() mod $rowsPerPage=0">
<xsl:text disable-output-escaping="yes">
<![CDATA[</table></DIV>]]>
</xsl:text>
<xsl:copy-of select="$pagefoot"/>
<xsl:copy-of select="$pagehead"/>
<xsl:text disable-output-escaping="yes">
<![CDATA[<DIV><table>]]>
</xsl:text>
</xsl:if>
<!--</xsl:if>-->
</xsl:template>
<xsl:template name="pagefoot">
<h6><DIV id="footer">
<xsl:value-of select="//pagefoot"/>
</DIV></h6>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list