Hi Helen,

cts:query is not well suited for testing absense of attributes and elements. 
Your for loop is rather verbose, have you tried compressing is to a single 
Xpath expression, for example:

doc()//ns1:a/ns1:sub[not(@temp1 or @temp2)]/base-uri(.)

Perhaps counter intuitive but it might perform even better when using 
doc()//ns1:sub instead of the extra ns1:a/. Not sure though..

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - 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
> Helen Chen
> Sent: woensdag 20 januari 2010 16:56
> To: General Mark Logic Developer Discussion
> Cc: Helen Chen
> Subject: [MarkLogic Dev General] question about cts:search
>
>
> Hi there,
> I'm using marklogic as my xml database, and I have a node inside xml
> like:
>
>   <ns1:a>
>     <ns1:sub  temp1="yes" temp2="no">...</ns1:sub>
>   </ns1:a>
>
> I have a large set of data, and I want to find out which xml
> file has
> <ns1:sub> node without attribute temp1 or attribute temp2.
>
> I tried to use the query like following:
>
> for $doc in fn:doc(), $sub in $doc//ns1:a/ns1:sub
> let $temp1 := $sub[fn:empty(./@temp1)]
> let $$temp2 := $sub[fn:empty(./@temp2)]
> where fn:exists($sub) and ( $temp1 or $temp2  )
> return
> fn:base-uri($i)
>
> but it took long time, I don't want to run it on production
> database.
> And using cts:query, I don't know how to check if an element has an
> attribute or not.
>
> Does anyone have any suggestions for this?
>
> Thanks, Helen
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
>

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to