Re: [xsl] Traversing a XML tree multiple times

Subject: Re: [xsl] Traversing a XML tree multiple times
From: "Vadim Permyakov" <vadimpermyakov@xxxxxxxxxxx>
Date: Sun, 30 Sep 2001 16:17:46 -0400
Hi, Jeroen

I had the same problem and we had to develop so called Multi-X Engine (MXE) to solve it. Unfortunately I simply cannot find time to put it on Internet for free download (inspite of the project was developed more then 1.5 year ago). But anyway I hope that it may be useful to reuse an idea, it is discrabed here:

http://www.softcorporation.com/xsl/mxtransf.html

The problem with making transformation in one shut was that it quickly becomes very messy and in a week later it is hard to understand what this transformation doing. As well we saw that to make several small transformations is faster then to do one but complicate.

By the way about global variables. We used extensions, so variable accessible not only from different nodes or templates but for all subsequent "traversals". Here is an example:

http://www.softcorporation.com/xsl/xsleasy3.html

I hope it may be useful. I think I would be able to find time to put it on Internet, but may be little later.

Vadim


From: "Paul Tyson" <paul@xxxxxxxxxxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [xsl] Traversing a XML tree multiple times
Date: Sun, 30 Sep 2001 12:13:34 -0700

Jeroen:

The answer is probably "yes", but without more specific information no one
could really say for certain.

You can "traverse" the document (or any portion of it) as many times as
needed simply by applying (or calling) templates. Remember, though, that
the entire document tree is accessible "all the time" when the document is
being processed--no matter which particular element or attribute template is
currently active. So, it is easy to select unique transformation of any
node based on characteristics of any other node, without explicitly
"traversing" the document repeatedly. You refer to other nodes in the
document with XPath expressions.


There are many different techniques of conditional transformation--the best
one for your application depends mostly on the particular structure of your
source documents, and the characteristics that must be selected to
conditionalize each stage of transformation.

If you are not familiar with functional programming techniques, you may be
frustrated with the variable-binding and -referencing capabilities of XSLT.
For instance, you can't set a variable value in one node, and then refer to
the variable to get that value while processing another node. Likewise, you
can't set a variable value during one "traversal", and then use it during a
subsequent "traversal". (You can, however, bind a top-level variable to the
result of applying a template. Then that variable-binding is visible within
all templates in the stylesheet.)


XSLT is most effective for problems that are conceptualized and stated as
tree transformation problems.  It can be terribly frustrating (and may not
be appropriate) for problems that only involve a sequence of imperative
commands on a serialized data set (which is what you get when you simply
"traverse" a document tree).

I'm sure you would get many suggestions from this list if you posted some
more specific information about your problem.

Good luck,
Paul Tyson
Precision Documents  http://precisiondocuments.com

----- Original Message -----
From: "Jeroen Benckhuijsen" <j.f.benckhuijsen@xxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Sunday, September 30, 2001 9:54 AM
Subject: [xsl] Traversing a XML tree multiple times


> Hi, > > I've been playing around with XML and XSLT lately and i really don't > have any clue how to solve this problem. I want to transform an XML > document using XSL. However i nedd to traverse the tree multiple times. > The first time i want to make a selection, the second a different > selection (based on the results of the first selection), etc. Is this > possible in 1 xsl document? > > TIA > > -- > Jeroen Benckhuijsen > > Software Engineer > Phoenix Software > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list >


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




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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



Current Thread