0
votes

I'm trying to return all authors of a set of records by running the following xquery :

for $a in /Record
return data($a/AuthorList/Author/Surname)

I've got this:

your query returned an empty sequence

I'm sure about the xpath but I don't know what is wrong with it.

1
Well, nothing is wrong with it. As the message says it obviously did not find any matching elements. You will have to show us (a snippet) of your XML data as it seems it doesn't match your query. - dirkk

1 Answers

3
votes

When you get no results, it often means your query was specific in ways that don't match your data. What I do is back off to something more general, then gradually get more specific.

Start with this:

for $a in /Record
return $a

Get anything? If not, you don't actually have any /Record items. Maybe you need a namespace? If you did get something, try:

for $a in /Record
return $a/AuthorList

Usually somewhere in this process, I find that I'd missed a namespace, or had the hierarchy wrong. That's as specific as I can be without seeing some of your data.