Reputation: 1048
I have some xml document. The structure of the documents are like this :-
<?xml version="1.0" encoding="UTF-8"?>
<patent-assignment>
<assignment-record>
<correspondent>
<name>NORTH AMERICA INTERNATIONAL PATENT OFFIC</name>
<address-1>P.O. BOX 506</address-1>
<address-2>MERRIFIELD, VA 22116</address-2>
</correspondent>
</assignment-record>
<patent-assignors>
<patent-assignor>
<assignor-name>TSAI, YU-WEN</name>
<execution-date>
<date>20050331</date>
</execution-date>
</patent-assignor>
<patent-assignor>
<assignor-name>HUANG, CHENG-I</name>
<execution-date>
<date>20050331</date>
</execution-date>
</patent-assignor>
</patent-assignors>
<patent-assignees>
<patent-assignee>
<assignee-name>FARADAY TECHNOLOGY CORP.</name>
<address-1>NO.10-2, LI-HSIN ROAD 1, SCIENCE-BASED INDUSTRIAL PARK</address-1>
<city>HSIN-CHU CITY</city>
<country-name>TAIWAN</country-name>
</patent-assignee>
</patent-assignees>
</patent-assignment>
I have created fields on assignor-name
and assignee-name
. Now I am running the cts:search
query like this:-
let $query:=cts:and-query((
cts:element-query(xs:QName("assignor-name"),
cts:field-word-query("Assignor Name", "apple")),
cts:element-query(xs:QName("assignee-name"),
cts:field-word-query("Assignee Name", "salix"))
))
for $x in cts:search(fn:doc(), $query)
return $x
where Assignor Name and Assignee Name are names of the fields which I have created. And these fields have assignor-name
and assignee-name
as their localname respectively. But when I am running this query it is giving me empty sequence. I have also checked my xml documents and documents have data where assignor-name
is "apple" and assignee-name
is "salix" still I am not getting the result. When I run this query only for assignor name or assignee name then I get results but when I combine them into an and-query
then I did not get any results. Please help.
Upvotes: 0
Views: 539
Reputation: 7842
Besides the namespace problem that Dave pointed out, the combination of element-query
and field-query
is unusual, and probably won't lead to satisfactory results.
For this query, you could drop both in favor of a simple cts:element-word-query
on the element.
Upvotes: 2
Reputation: 769
Yes, you can use the cts:element-word-query
function in the following manner:
cts:and-query((cts:element-word-query(xs:QName("pa:assignor-name"),
"apple",
"case-insensitive"
),
cts:element-word-query(xs:QName("pa:assignee-name"),
"salix",
"case-insensitive")
))
Upvotes: 1