472,805 Members | 820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

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 5613
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pete | last post by:
I am just getting to grips with XML and I was wondering if you could help me with something that no-one seems able or willing to help with.. I have an XSLT file which should be transforming a...
1
by: Lisa | last post by:
I need to apply the HTML formatting tags and the French accented characters in a XML document. The XML is generated from a database that has HTML tags and French accented characters in the records....
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
1
by: cameron | last post by:
I am attempting to pass in an XmlDocument as a parameter to a transform: from my sample ASPX page: string BaseDir = "/cameron/Play/ComplexParam/"; XmlDocument XSL = new XmlDocument();...
1
by: jrwarwick | last post by:
Hello, I believe I have uncovered a bug in the .Net XSLT engine to do with 'for' loops in XSLT. Here are the steps to reproduce it: -Create A new webform project. -Add the xml file...
1
by: Patrick.O.Ige | last post by:
I have a xml file and i want to format it using XSL My XSL file and XML below I needed to do a distinct which is ok on the first node "Code" For the "programDescription" i did below which gets the...
0
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections....
3
by: R. P. | last post by:
Subject: XSLT to transform a flat XML file into a structured text file I have an XML file that lists the PDF file segment names and titles of a larger document and looks something like this: ...
3
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.