XSL: find matching Traveler by position in XML (since no unique identifier is found)
I have the following xsl and input file.
I want to populate Loyal/@givenName & Loyal/@surname by matching the TravelerID with the POSITION of where TravelerName exists.
Example:
TravelerIDs[@ID=T1]/Info/FFNumber is linked to the 2nd Traveler in Request/TravelerName (i.e - JOHN DOE )
The way the TravelerName's are ordered is the same as the way the TravelerIds are odered
this variable
<xsl:variable name="position" select="position() - 1"></xsl:variable>
counts the number of TravelerIDs before the current TravelerIDs
I then use that variable in this expression
../TravelerName[count(preceding-sibling::TravelerName) = $position]
is the TravelerName that has a number of preceding sibling TravelerName elements equal to $position
in other words: it returns the TravelerName at the exact relative position as the TravelerIds we are currently processing
can you please explain how you are doing this?