#
# Params: RES_ID the ID of looked up resource
# RES_TYPE (option) the type of searched resource
for $resource in collection('/db/Profiles/<RES_TYPE ISdefault =''>')//Resource
where $resource/ID/string() eq '<RES_ID/>'
return $resource