XSLT - hierarchical probe of NodeSet query

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all,<br/>
<br/>
the goal of my query is to extract the <Entity> element within the NodeSet that is the ultimate owner. The logic that determines the ultimate owner is the following:<br/>
<br/>
OwnershipStructure, Ownership structure of the company the XML is based on. So we only get to know the upside hierarchy (companies that own this company) of the company and not the down the downside (who it owns etc).<br/>
<br/>
Entity/Number = 1, the current company which the XML is based on. As can be seen the element <ParentNumber> is empty, as we dont have the downside ownership information. So, the first company (Entity) is the current company.
Entity/Number = 2 AND ParentNumber/ParentNumber 1 AND Percentage = 100, this is the immediate parent of the company in <number>1 since the ParentNumber element tells us with the value 1. Also because the <Percentage> value is > 50%<br/>
<br/>
Now to find the ultimate parent, which is the part I am trying to achieve. The ultimate parent can be found at any level, meaning its <ParentNumber> value could be anything (within logical reason). However, we can only get to this ultimate parent <Entity>
if it, or subsequent parents have a Percentage value greater than 50% all the way up the chain. So it is posisble the ultimate parent is only half way up the <Entity> chain because its own parents all have a <Percentage> value which is < 50%<br/>
<br/>
Below is some example XML, where Entity/Number = 4 is the Ultimate parent.<br/>
<br/>
How do I construct a predicate rule which traverses the <Entity> NodeSet,using the rules i haved (tried!) to define above to get the ultimate parent <Entity>?


<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; OwnershipStructure<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Number<span style="color:Blue; >1<span style="color:Blue; </<span style="color:#A31515; Number<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParentNumber <span style="color:Red; xsi:nil<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >EVEREN<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Percentage <span style="color:Red; xsi:nil<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; true<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Number<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; Number<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParentNumber<span style="color:Blue; >1<span style="color:Blue; </<span style="color:#A31515; ParentNumber<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >ELEKTROWNIA<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Percentage<span style="color:Blue; >100<span style="color:Blue; </<span style="color:#A31515; Percentage<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Number<span style="color:Blue; >3<span style="color:Blue; </<span style="color:#A31515; Number<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParentNumber<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; ParentNumber<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >ENB ENERGIE<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Percentage<span style="color:Blue; >32.4<span style="color:Blue; </<span style="color:#A31515; Percentage<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Number<span style="color:Blue; >4<span style="color:Blue; </<span style="color:#A31515; Number<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParentNumber<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; ParentNumber<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >ELECTRICITE<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Percentage<span style="color:Blue; >52<span style="color:Blue; </<span style="color:#A31515; Percentage<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Number<span style="color:Blue; >5<span style="color:Blue; </<span style="color:#A31515; Number<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParentNumber<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; ParentNumber<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >ELEKTROCIEPŁOWNIE<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Percentage<span style="color:Blue; >18.8<span style="color:Blue; </<span style="color:#A31515; Percentage<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Number<span style="color:Blue; >6<span style="color:Blue; </<span style="color:#A31515; Number<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ParentNumber<span style="color:Blue; >5<span style="color:Blue; </<span style="color:#A31515; ParentNumber<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >EDF<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Percentage<span style="color:Blue; >99.74<span style="color:Blue; </<span style="color:#A31515; Percentage<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Entity<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; OwnershipStructure<span style="color:Blue; >
[/code]

Thanks


<hr class="sig Tryst

View the full article
 
Back
Top