473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 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 5691
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.