p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Count the number of output lines (http://p2p.wrox.com/showthread.php?t=30533)

joyces June 16th, 2005 09:36 PM

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

joyces June 21st, 2005 03:43 AM

mmm.. so i guess this is not possible?

barcher June 21st, 2005 04:00 AM

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 ??


joyces July 5th, 2005 08:13 PM

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.

joefawcett July 6th, 2005 01:08 AM

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)

mhkay July 6th, 2005 03:36 AM

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

joefawcett July 6th, 2005 09:40 AM

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)

mhkay July 6th, 2005 11:49 AM

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


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

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