RE: [xsl] remembering output

Subject: RE: [xsl] remembering output
From: paul.chubb@xxxxxxxxxx
Date: Fri, 10 Feb 2006 17:18:18 +1100
              I have thought about it for another week and now have a way
forward thanks to that research and your comments. So thankyou. For those
who are struggling with a similar problem I will outline my approach - note
this may not be the best approach but I am hoping it will do the job.

I have a source document that has formatting information stored in a number
of places for any given text. Linkage to text is either via enclosure or
via shared ids.

I am translating to another document format that combines all formating
into a single place and then links to text using ids.

This problem results in the need to identify a discrete set of output
formats and a way to link back to the text in the output document. The
actual number of formats is potentially the result of the number of linked
formats and embedded formats in the source document. However many may be

My solution is three passes:

1) translate the document by looking at each paragraph of text to create a
lookup table of ids, output formatting and information to identify the
paragraph on subsequent passes. This results in an xml file listing all the
possible output formats.

2) Create the format information: translate the document by looking at each
paragraph, check the paragraph doesn't use the same format as a paragraph
earlier in the document. If not lookup the first appropriate format for
that paragraph and output it

3) Create the text information: translate the document by translating each
paragraph. Link to the correct paragraph format by looking up the first
appropriate format.

The first one is a separate stylesheet. I think I can use mode for the
second and third pass.

Cheers Paul

             "Michael Kay"                                                                                                
             01/02/2006 10:22 PM           <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>                                              
               Please respond to                                                                                  Subject 
             xsl-list@xxxxxxxxxxxx         RE: [xsl] remembering output                                                   

> I have to do something like the following:
> Pass 1:
> 1) scan the text of the dxl file for <par>
> 2) check to see if the referenced paragraph style and the child font
> definition have been emitted before
> 3) If they haven't emit an appropriate odf style

Any description like this that uses words such as "before" and "after"
that you're thinking procedurally. There's no defined order of execution in
XSLT, so no "before" and "after". The word "remembering" in your title also
gives the game away: with no "before", there can be no memory of what has
gone before.

The first thing you have to do is to rewrite your requirements
so the output is described as a function of the input, and not of the state
of processing. This might be as simple as changing rule 2 to

"check to see if the referenced style is the first occurrence of that style
within the input document".

Michael Kay

Free publications and statistics available on

Current Thread