Note that there are some explanatory texts on larger screens.

plurals
  1. POxpath - matching value of child in current node with value of element in parent
    primarykey
    data
    text
    <p>Edit: I think I found the answer but I'll leave the open for a bit to see if someone has a correction/improvement.</p> <p>I'm using xpath in Talend's etl tool. I have xml like this:</p> <pre><code>&lt;root&gt; &lt;employee&gt; &lt;benefits&gt; &lt;benefit&gt; &lt;benefitname&gt;CDE&lt;/benefitname&gt; &lt;benefit_start&gt;2/3/2004&lt;/benefit_start&gt; &lt;/benefit&gt; &lt;benefit&gt; &lt;benefitname&gt;ABC&lt;/benefitname&gt; &lt;benefit_start&gt;1/1/2001&lt;/benefit_start&gt; &lt;/benefit&gt; &lt;/benefits&gt; &lt;dependent&gt; &lt;benefits&gt; &lt;benefit&gt; &lt;benefitname&gt;ABC&lt;/benefitname&gt; &lt;/benefit&gt; &lt;/dependent&gt; </code></pre> <p> </p> <p>When parsing benefits for dependents, I want to get elements present in the employee's benefit element. So in the example above, I want to get 1/1/2001 for the dependent's start date. I want 1/1/2001, not 2/3/2004, because the dependent's benefit has benefitname ABC, matching the employee's benefit with the same benefitname.</p> <p>What xpath, relative to /root/employee/dependent/benefits/benefit, will yield the value of benefit_start for the benefit under parent employee that has the same benefit name as the dependent benefit name? (Note I don't know ahead of time what the literal value will be, I can't just look for 'ABC', I have to match whatever value is in the dependent's benefitname element.</p> <p>I'm trying: </p> <p>../../../benefits/benefit[benefitname=??what??]/benefit_start </p> <p>I don't know how to refer to the current node's ancestor in the middle of the xpath (since I think "." at the point I have ??what?? will refer to the benefit node of the employee/benefits.</p> <p>EDIT: I think what I want is "current()/benefitname" where the ??what?? is. Seems to work with saxon, I haven't tried it in the etl tool yet.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload