[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How recursively iterate over entire document?

Subject: How recursively iterate over entire document?
From: chris <oneskiingfool@xxxxxxxxx>
Date: Thu, 11 Aug 2005 16:04:07 -0600
iterate document elements
Hi List,
It's kind of strange what I'm doing, so it's hard to explain.  I'll
try to keep it simple.  In my document that I'm trasnforming, I have a
sequence of elements that contain some xpath queries in them.... that
will be dynamically evaluated using evaluate().
These can't be evaluated consecutively on the same document, because
one will cause changes to the document that the next one has to see,

So in other words, I need to iterate over a sequence and for each
iteration, make changes to a document and pass it on to the next
iteration. In the end, I want only the single document with all the
changes to it.  I'm probably making no sense, so I'll try to
illustrate and example.

Source Documents
   <setting xpath="/company/departments">
      <department name="c"/>
   <setting xpath="/company/departments/department[@name='c']">
      <employees count="10"/>

    <department name="a"/>
    <department name="b"/>

Output Doc
    <department name="c">
      <employees count="10"/>
    <department name="a"/>
    <department name="b"/>


Please ignore the worthlessness of this example... it's just a
simplified example to illustrate what I'm trying to do.
As you can see, the first 'setting' element is adding a  new element
to the doc at the location specified by the 'xpath' attribute.  I have
no problem with doing just one.  The problem I have, is that the
second setting element has an xpath that is depended on the first one
already having been completed because, for example, department C does
not exist until it has been added.... and since this is not DOM, it's
getting a little complicated for me to conceptualize how to do this...

This doesn't work, but maybe will give some ideas....

<xsl:variable name="doc" select="document(company.xml)">
<xsl:for-each select="settings/setting">
  <xsl:variable name="doc">
    <xsl:apply-templates select="$doc">
        (tunnel setting element param...)
<xsl:sequence select="$doc"/>

Any ideas?


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.