Hi Andrew and Geert,

It did work much much faster and better, I can run it on production now. Thanks a lot.

And I got one problem:

at the end of the query, if I have /fn:document-uri(.), like my query is : fn:doc()/ns1:article//ns1:sub[fn:not(@temp1 or @temp2 )]/fn:document- uri(.) then I got empty sequence, but if I just run fn:doc()/ns1:article// ns1:sub[fn:not(@temp1 or @temp2 )] it does give me more than one node, and all the nodes all in the same document.


I changed document-uri to be base-uri, and I got error like
Description: XDMP-NOTANODE: doc()/child::ns1:article/ descendant::ns1:sub[not(attribute::temp1 or attribute::temp2)]/base- uri(.) -- xs:anyURI("/pt/ajr_1.xml") is not a node


I can loop through the result to find out the uri, but do you know why I cannot get result from the one line query?

Thanks, Helen

On Jan 20, 2010, at 11:00 AM, Andrew Welch wrote:

2010/1/20 Helen Chen <[email protected]>:

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?

how about:

//ns1:sub[not(@temp1)][not(@temp2)]/fn:document-uri(.)



--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
_______________________________________________
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