let $profiles := collection('/db/Profiles/')//Resource[ID/string() eq ''] let $relatedghn := collection('/db/Profiles/GHN')//Resource[ID/string() eq $profiles/Profile/GHN/@UniqueID/string()] let $ghn-name := if (empty($relatedghn/Profile/GHNDescription/Name/string())) then $profiles/Profile/GHN/@UniqueID/string() else $relatedghn/Profile/GHNDescription/Name/string() for $ri in $profiles return