Re: [xsl] Elements print sometimes only

Subject: Re: [xsl] Elements print sometimes only
From: tcn@xxxxxxxxxxxxx (Trevor Nash)
Date: Sat, 21 Jul 2001 09:21:56 GMT

>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:
In the text you say "statement/stmtPeriod" but in the template you add
'/' on the front.  This may be an important difference.

It looks like a problem with the current element, though its hard to
be sure as you do not give us a sample of the input.
Within the template "pagehead" you are referring to
/statement/stmtPeriod which is an absolute path, so will work in
whatever context pagehead is called.  But the things like "acctnum"
are relative paths.  These will only produce something if when you
call pagehead the current element has a child called "acctnum".

You probably need to pass statement/accountInfo as a parameter into
the pagehead template, or instead of saying 'acctnum' say

If the output from the pagehead template is the same for the whole
run, then it may be better to put the contents in a global variable
and copy that rather than doing a call-template.  Look up xsl:variable
and xsl:copy-of.

><xsl:template name="pagehead">
><DIV style="position: relative; top:4px;">
><xsl:value-of select="acctnum"/>
><span class="shiftright">
><xsl:value-of select="taxid"/>
><span class="shiftrightb">
><xsl:value-of select="/statement/stmtPeriod"/>
>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.

The most helpful thing you (and others) can do is first reduce the
stylesheet and input to give something that is easy to test.  Make
sure what you post still does what you claim - test it yourself first.

Often this process of elimination will reveal the answer without
having to post at all.

>Thanks.   Tamre

Trevor Nash
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 XSL-List info and archive:

Current Thread