Hi Geert,

It seems it is this problem. I tried

xquery version "1.0-ml";
(: buffer 2 :)
declare namespace ns = "http://tpox-benchmark.com/custacc";;

xdmp:query-trace(true()),(
for $cust in doc()
where $cust/ns:Customer/@id = 1002
return $cust
)

It gives out the result, but when I add prefix to attribute, it gives 
empty result.

xquery version "1.0-ml";
(: buffer 2 :)
declare namespace ns = "http://tpox-benchmark.com/custacc";;


xdmp:query-trace(true()),(
for $cust in doc()
where $cust/ns:Customer/@ns:id = 1002
return $cust
)

This is the first time I come across this problem, since I always use 
the default namespace and everything works well. So this means in an XML 
file, when I declare default namespace in root element but no namespace 
prefix in attribute, then the attribute is with no namespace? Like in my 
data xml file, the root node is like

<Customer id="1002" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://tpox-benchmark.com/custacc"; 
xsi:schemaLocation="http://tpox-benchmark.com/custacc 
custacc.xsd"><Mnemonic>LowrieJaved</Mnemonic>
<ShortNames><ShortName>Javed Lowrie</ShortName>...</Customer>

If I want the attribute also be included in the same default namespace, 
I have to write like
<Customer xs:id="1002"
xmlns:xs="http://tpox-benchmark.com/custacc";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns="http://tpox-benchmark.com/custacc"; ...

Right?

I am recreating my index to remove the namespace from the attribute but 
keep the namespace in the parent node and see the result. Thank you very 
much!!

Thanks,
Ling


Geert Josten wrote:
> Hi Ling,
> 
> There is something peculiar with attributes and namespaces. You must to 
> prefix attributes to make them take part of a namespace. No prefix on 
> attributes means by definition no namespace. This only applies to attributes.
> 
> So, what happens if you start using a prefix in your code? ;-)
> 
> Kind regards,
> Geert
> 
> 
> 
> drs. G.P.H. (Geert) Josten
> Consultant
> 
> 
> Daidalos BV
> Hoekeindsehof 1-4
> 2665 JZ Bleiswijk
> 
> T +31 (0)10 850 1200
> F +31 (0)10 850 1199
> 
> mailto:[email protected]
> http://www.daidalos.nl/
> 
> KvK 27164984
> 
> P Please consider the environment before printing this mail.
> De informatie - verzonden in of met dit e-mailbericht - is afkomstig van 
> Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit 
> bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit 
> bericht kunnen geen rechten worden ontleend.
> 
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> Ling Ling
>> Sent: donderdag 6 mei 2010 17:58
>> To: General Mark Logic Developer Discussion
>> Subject: Re: [MarkLogic Dev General] attribute range index
>>
>> Hi Danny,
>>
>> Yes, I have default namespace declared. I tried the query in cq,
>>
>> xquery version "1.0-ml";
>> (: buffer 2 :)
>> declare namespace html = "http://www.w3.org/1999/xhtml";;
>> declare default element namespace "http://tpox-benchmark.com/custacc";;
>>
>> xdmp:query-trace(true()),(
>> for $cust in doc()
>> where $cust/Customer/@id = 1002
>> return $cust
>> )
>>
>> I don't know why. Thank you very much!
>>
>> Ling
>>
>>
>> Danny Sokolsky wrote:
>>> What namespace is your element and attribute in, and what
>> namespace is your range index in?  It looks (according to the
>> query trace) like both the element and the attribute are in
>> the http://tpox-benchmark.com/custacc namespace, but the
>> first query is requesting the id attribute in no namespace.
>> Maybe somewhere here lies the clue?  Do you have any default
>> namespaces in play here?
>>> -Danny
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Ling
>>> Ling
>>> Sent: Wednesday, May 05, 2010 3:53 PM
>>> To: [email protected]
>>> Subject: [MarkLogic Dev General] attribute range index
>>>
>>> Hello,
>>>
>>> I have a question about query and attribute range query I have a
>>> customer xml file stored in database and an attribute range
>> index on
>>> Customer id, if my query is like:
>>>
>>> for $cust in doc()
>>> where $cust/Customer/@id = 1002
>>> return $cust
>>>
>>> The range index is not used and the trace file is here:
>>>
>>> Info: benchHttp: line 7: xdmp:eval("xquery version
>>> &quot;1.0-ml&quot;;&#13;&#10;(: buffer 2 :)&#13;&...", (), <options
>>>
>> xmlns="xdmp:eval"><root>benchHttp</root><isolation>different-transacti
>>> on</isolatio...</options>)
>>> Info: benchHttp: line 7: Analyzing path for $cust: fn:doc()
>>> Info: benchHttp: line 7: Step 1 is searchable: fn:doc()
>>> Info: benchHttp: line 7: Path is fully searchable.
>>> Info: benchHttp: line 7: Gathering constraints.
>>> Info: benchHttp: line 7: Step 1 contributed 1 constraint: fn:doc()
>>> Info: benchHttp: line 8: Comparison contributed hash value
>> constraint:
>>> Customer/@id = 1002
>>> Info: benchHttp: line 7: Where clause contributed 2 constraints for
>>> $cust: $cust/Customer/@id = 1002
>>> Info: benchHttp: line 7: Executing search.
>>> Info: benchHttp: line 7: Selected 1 fragment to filter
>>>
>>> If I wrote query like this:
>>>
>>> cts:search(doc()/Customer,
>>> cts:element-attribute-range-query(xs:QName("Customer"),
>>> xs:QName("id"), "=" ,1002))
>>>
>>> xdmp:query-trace(true()),(
>>> cts:search(doc()/Customer,
>>> cts:element-attribute-range-query(xs:QName("Customer"),
>>> xs:QName("id"), "=" ,1002))
>>> )
>>>
>>> The index is used but no results returned. Here is the trace file:
>>>
>>> line 7: xdmp:eval("xquery version &quot;1.0-ml&quot;;&#13;&#10;(:
>>> buffer
>>> 2 :)&#13;&...", (), <options
>>>
>> xmlns="xdmp:eval"><root>benchHttp</root><isolation>different-transacti
>>> on</isolatio...</options>) line 7: Analyzing path for search:
>>> fn:doc()/Customer line 7: Step 1 is searchable: fn:doc()
>> line 7: Step
>>> 2 is searchable: Customer line 7: Path is fully searchable.
>>> line 7: Gathering constraints.
>>> line 7: Step 2 test contributed 1 constraint: Customer line 7:
>>> Comparison contributed int range value constraint:
>> Customer/@id = 1002
>>> line 7: Search query contributed 1 constraint:
>>>
>> cts:element-attribute-range-query(fn:QName("http://tpox-benchmark.com/
>>> custacc", "Customer"),
>> fn:QName("http://tpox-benchmark.com/custacc";,
>>> "id"), "=", 1002, (), 1) line 7: Executing search.
>>> line 7: Selected 0 fragments to filter
>>>
>>> Could you show me the reason? Thank you very much!
>>>
>>> Regards,
>>> Ling
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>> _______________________________________________
>>> General mailing list
>>> [email protected]
>>> http://developer.marklogic.com/mailman/listinfo/general
>>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> 
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to