Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2005, 09:36 PM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count the number of output lines

Hi,

Is there a way to count the number of lines that would be in the output file?

Thanks
 
Old June 21st, 2005, 03:43 AM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmm.. so i guess this is not possible?
 
Old June 21st, 2005, 04:00 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

A better explanation/example of what it is you are trying to achieve might provoke a better response.
For example are you outputting html / text ??

 
Old July 5th, 2005, 08:13 PM
Registered User
 
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

outputting text.

Basically I would like to know a count of lines that I have outputted.

Alternatively, in the xslt, there is actually only one dynamic part, and i was wondering what is the easiest way to count the number of lines there.
 
Old July 6th, 2005, 01:08 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It depends on the data, you could calculate how many lines are going to be output using XPath functions.

You could also use the xsl:number element to number the lines as they are output but you might not want them numbered.

If neither of those is possible then you'll have to resort to a non XSLT method, e.g. open the file using standard file io methods.

--

Joe (Microsoft MVP - XML)
 
Old July 6th, 2005, 03:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This kind of problem is best addressed by adding a second stylesheet to your processing pipeline; the second stylesheet simply counts the number of lines in its input document.

The way you implement a pipeline of stylesheets depends on the environment you are running in, but it's a very useful technique whatever the environment.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old July 6th, 2005, 09:40 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Quote:
quote:Originally posted by mhkay
 This kind of problem is best addressed by adding a second stylesheet to your processing pipeline; the second stylesheet simply counts the number of lines in its input document.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Can this be done when the first output is a text file though?

--

Joe (Microsoft MVP - XML)
 
Old July 6th, 2005, 11:49 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No, in a processing pipeline each stage except the last produces a result tree which acts as the source tree for the next phase. The last phase can serialize as text. But you only need to wrap the text in a dummy element to make it a valid XML tree.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList and number of lines snufse1 ASP.NET 2.0 Basics 0 September 19th, 2008 02:52 PM
to count amount of lines in string glaudsonsilva C# 1 July 19th, 2007 03:10 PM
Need to Count number of lines in a file lawsoncobol Access VBA 2 July 19th, 2007 04:28 AM
how to count lines in word file arshad mahmood VB How-To 2 June 7th, 2006 09:40 PM
How to count lines in ASP arshad mahmood Classic ASP Professional 3 June 7th, 2006 09:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.