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

G

gualtmacchi

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.
 
J

johkar

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
 
G

gualtmacchi

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.
 
E

Edwin Kapauni

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?
 
P

Peter Flynn

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top