473,903 Members | 4,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5749
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*********@yah oo.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*********@yah oo.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
2753
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 straight XML file http://www.discovertravelandtours.com/test/templates/test.xml?Location=Germany To another XML file http://www.discovertravelandtours.com/test/templates/test2.xml?Location=Germany
1
5585
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. I have specified <xsl:output method="html"/> and encoding="iso-8859-1". When I apply the xsl:value-of and set the disable-output-escaping to "yes", the HTML formatting tags are displayed correctly, but the French accented characters are...
4
1836
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
2375
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(); XSL.Load(HttpContext.Current.Server.MapPath(BaseDir + "xsl.xsl")); XmlDocument Data = new XmlDocument();
1
1649
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 'errorexample.xml' - it is shown at the bottom -Add the xslt file 'errorexample.xslt' - it is shown at the bottom -Add a label into the WebForm1.aspx designer and stretch it so it is large, give it the ID of Output1. -Import the following namespaces in...
1
4107
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 Count of the nodes and i get the programDescription node but it duplicates for the selected "Code" Node. So if the Count is 3 its shows values "Crazy Training 2" 3 times for Code "PRG004" Any help?
0
3310
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. Each section has a list of questions. Each question has responses. I need to display a list of responses to the questions (i.e. set:distinct), once and only once, each section. My second problem is that these questions can also have corrective...
3
2763
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: <DOCUMENT> ...... ...... some lead elements ...... <SEGMENT_LIST>
3
9641
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 difference between two source documents and output node-sets which are "different" (changed or new) to new XML files using xsl:result-document To describe the problem I have provided some example data below along with my a portion of my current...
0
9999
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11285
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10878
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10986
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8049
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7208
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3324
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.