Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 16th, 2005, 09:36 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old June 21st, 2005, 03:43 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmm.. so i guess this is not possible?
Reply With Quote
  #3 (permalink)  
Old June 21st, 2005, 04:00 AM
Authorized User
 
Join Date: Jul 2004
Location: Oxford, , United Kingdom.
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 ??

Reply With Quote
  #4 (permalink)  
Old July 5th, 2005, 08:13 PM
Registered User
 
Join Date: Jun 2005
Location: , , .
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.
Reply With Quote
  #5 (permalink)  
Old July 6th, 2005, 01:08 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
Reply With Quote
  #6 (permalink)  
Old July 6th, 2005, 03:36 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
  #7 (permalink)  
Old July 6th, 2005, 09:40 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
Reply With Quote
  #8 (permalink)  
Old July 6th, 2005, 11:49 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:51 PM.


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