|
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
|
|
|
June 16th, 2005, 09:36 PM
|
Registered User
|
|
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
June 21st, 2005, 03:43 AM
|
Registered User
|
|
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
mmm.. so i guess this is not possible?
|
June 21st, 2005, 04:00 AM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 ??
|
July 5th, 2005, 08:13 PM
|
Registered User
|
|
Join Date: Jun 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
July 6th, 2005, 01:08 AM
|
|
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
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)
|
July 6th, 2005, 03:36 AM
|
|
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
July 6th, 2005, 09:40 AM
|
|
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
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)
|
July 6th, 2005, 11:49 AM
|
|
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|
|