[xsl] Elements print sometimes only

Subject: [xsl] Elements print sometimes only
From: "Tamre2" <tamre2@xxxxxxx>
Date: Fri, 20 Jul 2001 15:30:23 -0700
I have the following xsl file that prints a header, middle section and a
footer--on each page.  On the first page in the header area three elements
print out in a line, namely "acctnum", "taxid" and "statement/stmtPeriod",
as shown here:

<xsl:template name="pagehead">
<DIV style="position: relative; top:4px;">
<xsl:value-of select="acctnum"/>

<span class="shiftright">
<xsl:value-of select="taxid"/>
</span>

<span class="shiftrightb">
<xsl:value-of select="/statement/stmtPeriod"/>
</span>
</DIV>

but when this is called the second time through, only the
"statement/stmtPeriod" prints out.  I have not been able to figure this out.
Any ideas?  I have posted the entire file below, in case it will be helpful.
Thanks.   Tamre


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="html"/>


<xsl:template match="/">


<html>
<head>
<link rel="Stylesheet" href="statement.css" type="text/css"/>
</head>


<body>
<xsl:for-each select="statement/accountInfo">

<xsl:call-template name="pagehead">
</xsl:call-template>

<xsl:call-template name="pagetable">
</xsl:call-template>

</xsl:for-each> <!--statement/accountInfo-->


</body>
</html>
</xsl:template>

<xsl:template name="pagehead">
<DIV style="position: relative; top:4px;">
<xsl:value-of select="acctnum"/>

<span class="shiftright">
<xsl:value-of select="taxid"/>
</span>

<span class="shiftrightb">
<xsl:value-of select="/statement/stmtPeriod"/>
</span>
</DIV>

<DIV style="position: relative; height:.75in; 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>

<!--<h4>
<xsl:value-of select="/statement/title"/></h4>
</DIV>-->

<DIV style="position: relative; top:12px; 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 name="pagetable">
<DIV style="position: relative; top:10px;">
<table id="table1">
<caption><xsl:value-of
select="/statement/accountInfo/acctnum"/>&#xa0;<!--whitespace between
elements--><xsl:value-of
select="/statement/accountInfo/accttitle"/></caption>

<caption id="caption2">
<xsl:value-of select="/statement/text"/>&#xa0;<xsl:value-of
select="format-number(transactions/@beginBal,'#,##0.00DB;#,##0.00CR')"/></ca
ption>


<xsl:for-each select="transactions/transaction">

   <xsl:variable name="rowsPerPage" select="8"/>

<xsl:call-template name="rowcount">
</xsl:call-template>

   <xsl:if test="position() mod $rowsPerPage=0">

   <xsl:text disable-output-escaping="yes">
   <![CDATA[</table></DIV>]]>
   </xsl:text>


<xsl:call-template name="pagefoot">
   </xsl:call-template>

   <xsl:call-template name="pagehead">
   </xsl:call-template>

   <xsl:text disable-output-escaping="yes">
   <![CDATA[<DIV><table>]]>
   </xsl:text>
   </xsl:if>


</xsl:for-each> <!--transactions/transaction-->

</table>
</DIV>
</xsl:template>


<xsl:template name="rowcount">
<tr>

<td width="65px" align="left"><xsl:value-of select="date"/>&#xa0;</td>
<td width="70px"><xsl:value-of select="long"/>&#xa0;</td>
<td width="70px"><xsl:value-of select="short"/>&#xa0;</td>
<td width="225px"><xsl:value-of select="description"/>&#xa0;</td>
<td width="50px" align="center"><xsl:value-of
select="priceCode"/>&#xa0;</td>


<td width="160px" align="right">
<xsl:if test="substring(amount,1,1)!='-'">
<xsl:value-of
select="format-number(amount,'#,##0.00')"/>&#xa0;</xsl:if></td>

<td width="160px" align="right">
<xsl:if test="substring(amount,1,1)='-'">
<xsl:value-of
select="format-number(amount,'#,##0.00')"/>&#xa0;</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)+//@b
eginBal,'#,##0.00DB;#,##0.00CR')"/>&#xa0;
</xsl:otherwise>
</xsl:choose>

</td>
</tr>
</xsl:template>


<xsl:template name="pagefoot">
<h6><xsl:value-of select="//pagefoot"/></h6>

</xsl:template>

</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread