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

Reply via email to