wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes xsl and plain text output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsl and plain text output" Watch "xsl and plain text output" New topic
Author

xsl and plain text output

joe burkey
Greenhorn

Joined: Aug 23, 2002
Posts: 1
Hi all. I am just looking for some advice. My problem is that I have an xml doc that contains invoice information. eg <invoice_header> which contains name, address, current date etc. The document also contains multiple <invoice_line>tags which contains information on price, line description quantity and rate of tax etc. It also contains a <line_text>tag which can have multiple freeform line text. The <invoice_line> also contains a <deliver_address> tag.
My problem is that I have to write an xsl stylesheet which can format this information and the produce a plain text file for printing on a line printer.
And secondly, while I am formatting the text in the stylesheet I have to keep track of the amount of lines that have been printed and the amount of line space left on a page before scrolling down to a new page and inserting the header and then carrying on inserting the invoice lines and any associated delivery address or line text lines as well.
So basically my question is, Is there any examples of this on the web or am I mad and is there an easier way of doing this. Also bare in mind that I am also new to the xsl language.
Thanks in advance.
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Joe, unfortunately your name doesn't formally comply with our official policy on registered names. There has to be a blank between a first and last name. Please, take a moment and change your publicly displayed name.
Sorry for nitpicking!
It's not clear if your header contains the same information for all pages or not. In the former case it's probably easier to write XSLT that is only concerned with XML -> plain text transformation and then to feed its output to another program that would do pagination.
It's possible to do all the job with XSLT, but this will complicate its structure.
You can factor your header out in a separate template, like
<xsl:template name="header">
and then call it from the main template as
<xsl:call-template name="header"/>
How to count lines depends on the sctructure of your data, here is one example that uses position() function.
Or you could maintain line counter yourself (which isn't too elegant a solution)
<xsl:variable name="lineCounter" select="$lineCounter + 1"/>
Finally, here is a relevant discussion why you do not want to do pagination in XSLT


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xsl and plain text output