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

RE: Finding corresponding node in structurally identic

Subject: RE: Finding corresponding node in structurally identical sibling tree?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 26 Apr 2002 11:21:23 +0100
xslt nod count
> I need to quickly find the matching node to the current node
> which is in a parallel branch with identical structure to the
> branch I'm operating in. It seems like this should be really
> simple, but the only solution I can come up with is
> a recursive template to assemble the name of the path from
> the branch tag down, and then compare that against the result
> from the same template for each node in the second tree. The
> trees may be of arbitrary depth. Any other ideas?

Depends what you mean by "quickly", but you could try:

<xsl:variable name="branch1index"
select="count(/example/branch1/preceding::node())"/>
<xsl:variable name="thisindex" select="count(preceding::node())"/>

select="/example/branch2/descendant::node[$thisindex - $branch1index]"

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

>
> <example>
>   <branch1>
>      <somestuff>
>          <somedeeperstuff>
>              <someevendeeperstuff/> <--- Current node
>          </somedeeperstuff>
>      </somestuff>
>   </branch1>
>   <branch2>
>      <somestuff>
>          <somedeeperstuff>
>              <someevendeeperstuff/> <--- Corresponding node I
> want to find
>          </somedeeperstuff>
>      </somestuff>
>   </branch2>
>  </example>
>
> The reason we are doing this is to be able to cache a form
> description in the first branch.
> Then any default values are placed in the second branch which
> means that we don't need to modify the
> cached document fragment.
>
> TIA
>
> Joel
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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-2011 All Rights Reserved.