-1

I have to create an XML mapping by entering one single XPath (1.0) for each item; worked fine until I now got an XML document like this:

<PARTIES>       
        <PARTY>         
                <PARTY_ID type="supplier_specific">12345</PARTY_ID>
                <ADDRESS>
                        <NAME>A</NAME>
                </ADDRESS>
        </PARTY>        
        <PARTY>         
                <PARTY_ID type="buyer_specific">54321</PARTY_ID>
                <ADDRESS>
                        <NAME>B</NAME>
                </ADDRESS>
        </PARTY>        
        <PARTY>         
                <PARTY_ID>delivery</PARTY_ID>
                <ADDRESS>       
                        <NAME>C</NAME>
                </ADDRESS>      
        </PARTY>        

        <PARTIES_REFERENCE>
                <BUYER_IDREF type="supplier_specific">12345</BUYER_IDREF>
                <SUPPLIER_IDREF type="buyer_specific">54321</SUPPLIER_IDREF>
                <DELIVERY_IDREF>delivery</DELIVERY_IDREF>
        </PARTIES_REFERENCE>

</PARTIES>

The idea is: if you want the delivery addres, then look at <DELIVERY_IDREF>, take the identifier from there ("delivery") and look for a <PARTY><PARTY_ID> with the same identifier. Result is the <ADDRESS> at the very same level.

So, if I want to know the <NAME> of the delivery address - how do I get there with a single XPath 1.0 expression? I have done quite a number of mappings, but this seems to be the next level, if possible at all.

SlowFox
  • 63
  • 5

2 Answers2

0

Like this :

/PARTIES/PARTY[./PARTY_ID=/PARTIES/PARTIES_REFERENCE/DELIVERY_IDREF/text()]/ADDRESS/NAME/text()
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
0

What comes to my mind :

//PARTY_ID[text()=string(//DELIVERY_IDREF)]/following::NAME[1]/text()

Output : C

E.Wiest
  • 5,425
  • 2
  • 7
  • 12