The xpath expression I created was something like:
$body/maat:requestDoc/maat:dataElement/maat:functies/maat:functie[$functieIndex]/text()But although I checked the value of the variable functieIndex using alerts, I always got the complete set of 'functie'-elements. But when I explicitly filled in '1' as a index I got the denoted element, like this:
$body/maat:requestDoc/maat:dataElement/maat:functies/maat:functie[1]/text()I checked with a co-worker, and he confirmed that what I did was just how it should work. Now, thinking my brains almost to cooking temperature, I came up with the idea: 'what if it does not know it is a number?'. So I explicitly casted the $functieIndex variable to int:
$body/maat:requestDoc/maat:dataElement/maat:functies/maat:functie[xs:int($functieIndex)]/text()And this works! Apparently somehow OSB does not know that the variable it declares for the sake of indexing a for-each is an integer by nature.
By the way, in this example I get the value also by the for-each variable. But sometimes You need the index-variable to index from another element-set.
Kudos to you!
ReplyDelete