469,612 Members | 1,592 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

XSLT: how to count records in the output text file?

I'm processing an XML input file getting a plain text file where from M
nodes I got N output lines...
It's not relevant but the input file is a recordset coming from a
database and the output is an EDI message set.

Now I need to put into the output file also some information regarding
just the output file itself and not the input one. And it cannot be
expressed in terms of input information.
For example I need to determine and write how many number of lines in
the output file are matching some conditions. Or I need to count the
total number of records the output file is made of.
(I need to compute the check records that the EDI wants somewhere in
the messages..)

So the question is: how can I do some counting, numbering, summing..
into the output file whilst I'm building it?
I'd like to avoid a two step processing.

Can XSLT handle it someway?

Thanks for any help.

Jan 10 '06 #1
4 5391
I am still unsure of what you are wanting. You can count() nodes or
matching nodes. Do a search on this newsgroup on count() if that is
what you want.

count(/pathtothes/node) and this will output a number representing the
matches. It is also valid to do count() + 1, etc.

John

Jan 11 '06 #2
If I'm not wrong count() works just on the input file.

I have instead to do some counting on the outputfile.
Don't know if XSLT has the ability to do some computation on the output
file. But that's what I'd need.
Otherwise I should express the computation in terms of the input but it
would be really complex as 1 input node is related to many output text
lines depending on many conditions varying from node to node.

G.

Jan 11 '06 #3
gu*********@yahoo.com wrote:
If I'm not wrong count() works just on the input file.

I have instead to do some counting on the outputfile.

[...]
What about doing the counting and other computations in a second step
transformation?
Jan 11 '06 #4
gu*********@yahoo.com wrote:
If I'm not wrong count() works just on the input file.

I have instead to do some counting on the outputfile.
XSLT cannot access the destination tree in this way.
Don't know if XSLT has the ability to do some computation on the output
file. But that's what I'd need.

Otherwise I should express the computation in terms of the input but it
would be really complex as 1 input node is related to many output text
lines depending on many conditions varying from node to node.


The only alternative to doing it by computation (ie reproducing the
steps in the computational calculation) is to perform those steps in
a recursive named template, where you can add n to m at each stage
and pass the result as a parameter to the next iteration (then output
it at the end).

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jan 11 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Pete | last post: by
1 post views Thread by Lisa | last post: by
4 posts views Thread by Chris Kettenbach | last post: by
1 post views Thread by cameron | last post: by
1 post views Thread by jrwarwick | last post: by
reply views Thread by DAnne | last post: by
3 posts views Thread by super.raddish | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.