[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Number of scans required ??


Subject: RE: [xsl] Number of scans required ??
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 14 Aug 2003 09:36:36 +0100

> If i got it properly, you mean to say that once i have 
> written something in 
> the output file i can not come to the point to rewrite 
> something again in the 
> same output file??  So the kind of output I want to obtain is 
> impossible with xsl ?

Everything is possible in XSLT, but you have to understand its
processing model and use it the way it was designed to be used.

The result of the transformation is a tree. The structure of the result
tree matches the structure of the stylesheet used to create it (the
stylesheet consists of templates for the nodes in the result tree). You
therefore need to design the stylesheet according to the structure of
the desired output. Where the structure of the source tree and result
tree are different, a common mistake is to try and model the stylesheet
on the structure of the source tree: this doesn't work.

Your mental process should be to picture the result tree that you want
to produce, then for each node in the result tree, to think "where does
the source data for this node come from", and to write the template that
produces this node in the result tree to fetch the required data from
the source document either using direct XPath expressions, or by using
XSLT-level instructions (apply-templates and for-each) to navigate to
the relevant part of the source tree.

I've tried to get this across to you in several of my replies on this
thread. The very title of the thread "number of scans required" shows
that you are thinking about XSLT processing the wrong way. Your thinking
should be output-driven, not input-driven.

In your case the structure of the result tree is a header followed by a
body. The header contains entries describing columns. The body contains
data rows, and each data row contains a sequence of values. This, in
essence, gives you the high level design of your stylesheet.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords