This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Traversing a XML tree multiple times


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@home.nl>
To: <XSL-List@lists.mulberrytech.com>
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]