Hi,
The reason for the unexpected result is that by using a ?let? clause you bind all phones of a person to variable $b. In the ?where? clause you just check if there is a ?home? phone bound to $b. If this is the case you return all phones of a person by returning $b.
To get the only the ?home? phones you have to replace the ?let? by a ?for? clause in the following way:
for $a in input()/person
for $b in $a/phone
where $b/@type=“home”
return $b
A shorter variant of this query is the following:
for $b in input()/person/phone
where $b/@type=“home”
return $b
The shortest variant just consists of a single path expression:
input()/person/phone[@type=“home”]
Best regards,
Thorsten Fiebig
#API-Management#webMethods#Tamino