Change value of Variable

View: New views
6 Messages — Rating Filter:   Alert me  

Change value of Variable

by saqi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
I've a situation in which i have to count the number of transactions/records, retrieved from my XML document, on one page. I have to show that number at the end of each page, with this I've to also show the total number of records in one document. I figure it will be solved by using variables but still can't find the way to solve this issue, as variables can only be defined once and it cannot be accessed outside the boundary in which it is defined. Is there any possible way supported by XSLT?
Thanks for your Help!
Regards,
Saqib javed

Re: Change value of Variable

by sonika_nitj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you are using <xsl:for-each select=""/> to iterate your records then you can use position() function to get the record number.
e.g.
 <xsl:for-each select="$Employees/Employee">
        <xsl:variable name="iCount" select="position()" />
...........Do Something...........
</xsl:for-each>

saqi wrote:
Hello,
I've a situation in which i have to count the number of
transactions/records, retrieved from my XML document, on one page. I have to
show that number at the end of each page, with this I've to also show the
total number of records in one document. I figure it will be solved by using
variables but still can't find the way to solve this issue, as variables can
only be defined once and it cannot be accessed outside the boundary in which
it is defined. Is there any possible way supported by XSLT?
Thanks for your Help!
Regards,
Saqib javed

Re: Change value of Variable

by saqi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello sonika_nitj,
Thanks for your reply. I have already tried that. now the situation is that if my data overflows from one page to 2nd and then to 3rd and so on, in this case i want to show the count,how many records on one page occured, at the end of each page.how can i do this?
i hope you got my point.
thanks
Regards,
Saqib Javed

On Mon, Oct 20, 2008 at 11:12 AM, sonika_nitj <sonika.janagill@...> wrote:


If you are using <xsl:for-each select=""/> to iterate your records then you
can use position() function to get the record number.
e.g.
 <xsl:for-each select="$Employees/Employee">
       <xsl:variable name="iCount" select="position()" />
...........Do Something...........
</xsl:for-each>


saqi wrote:
>
> Hello,
> I've a situation in which i have to count the number of
> transactions/records, retrieved from my XML document, on one page. I have
> to
> show that number at the end of each page, with this I've to also show the
> total number of records in one document. I figure it will be solved by
> using
> variables but still can't find the way to solve this issue, as variables
> can
> only be defined once and it cannot be accessed outside the boundary in
> which
> it is defined. Is there any possible way supported by XSLT?
> Thanks for your Help!
> Regards,
> Saqib javed
>
>

--
View this message in context: http://www.nabble.com/Change-value-of-Variable-tp20063020p20063750.html
Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.




Re: Change value of Variable

by Dave Pawson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


2008/10/20 Saqi <saqib.javed@...>:
> Hello sonika_nitj,
> Thanks for your reply. I have already tried that. now the situation is that
> if my data overflows from one page to 2nd and then to 3rd and so on, in this
> case i want to show the count,how many records on one page occured, at the
> end of each page.how can i do this?

You can't do this.

1. There is no feedback from the page layout (formatter) software to the XSLT.
2. 'Variables' in xsl-fo are immutable. Think of them as constants that you set.

You need to think of your problem in a different way.


regards



--
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.
http://www.dpawson.co.uk


Re: Change value of Variable

by Liam Quin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, Oct 20, 2008 at 11:22:28AM +0500, Saqi wrote:
> if my data overflows from one page to 2nd and then to 3rd and so on, in this
> case i want to show the count,how many records on one page occured, at the
> end of each page.how can i do this?

We added some extra table-marker support in FO 1.1, e.g. so that you can
show a subtotal of values on a page; you could probably use this
mechanism, depending on whether your formatter supports FO 1.1.
E.g. give each record a value of "1" but show only the total of
those values on each page.

Maybe someone else on this list can tell me if this might work ;-)

Liam

--
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin/
http://www.holoweb.net/~liam/ * http://www.fromoldbooks.org/


Re: Change value of Variable

by Tony Graham-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, Oct 20 2008 09:29:06 +0100, liam@... wrote:

> On Mon, Oct 20, 2008 at 11:22:28AM +0500, Saqi wrote:
>> if my data overflows from one page to 2nd and then to 3rd and so on, in this
>> case i want to show the count,how many records on one page occured, at the
>> end of each page.how can i do this?
>
> We added some extra table-marker support in FO 1.1, e.g. so that you can
> show a subtotal of values on a page; you could probably use this
> mechanism, depending on whether your formatter supports FO 1.1.
> E.g. give each record a value of "1" but show only the total of
> those values on each page.
>
> Maybe someone else on this list can tell me if this might work ;-)

It appears similar to the example in the spec at
http://www.w3.org/TR/xsl11/#d0e14681 so it should work if the records
can be formatted in a table.

Regards,


Tony Graham                         Tony.Graham@...
Director                                  W3C XSL FO SG Invited Expert
Menteith Consulting Ltd
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599   http://www.menteithconsulting.com
  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
xmlroff XSL Formatter                               http://xmlroff.org
xslide Emacs mode                  http://www.menteith.com/wiki/xslide
Unicode: A Primer                               urn:isbn:0-7645-4625-2