user1462294
user1462294

Reputation: 167

XQuery clause not yielding any results

The goal for this query is to print the list of employee names that live in San Fran.

Here is the clause I've written:

for $x in doc("data.xml")/EmpDatabase/PersonList/Person
where $x/City="San Fran"
order by $x/Name
return $x/Name

Here is the data's template schema (of which I've populated with data in my data.xml file):

<EmpDatabase>

<PersonList Type="Employee">
<Title Value="Employee List"/>
<Contents>
     <Person>
          <Name></Name>
          <Street></Street>
          <City></City>
     </Person>
</Contents>
</PersonList>

</EmpDatabase>

And here's how I'm running the query on the Windows command line:

java -jar kawa-1.9.1.jar --xquery -f emp.xquery -> results.xml

However, when I run this command, the command line acts as though the query was successful but results.xml is an empty file...

Can you take a look at this to see what I may be doing wrong in my xquery file? Any help is appreciated!

Upvotes: 0

Views: 88

Answers (1)

Loren Cahlander
Loren Cahlander

Reputation: 1347

Try:

for $x in doc("data.xml")//PersonList/Person[City/text() ="San Fran"]
order by $x/Name
return $x/Name/text()

Upvotes: 0

Related Questions