Hi Sudheer,<div><br></div><div>You can use xpath expression with predicate like </div><div><br></div><div><b>//entrylist/entry[identity/id/text()=&#39;*&#39; and not(permissionList/permission=&#39;read&#39;)]</b></div><div>
<br></div><div> to test the below highlighted.</div><div><br></div><div>Regards,</div><div>Vishnu<br><br><div class="gmail_quote">On Wed, Mar 28, 2012 at 12:19 AM, Sudheer Yalaverthi <span dir="ltr">&lt;<a href="mailto:sudheer.yalaverthi@gmail.com">sudheer.yalaverthi@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Damon,<br><br>I have made the xml simple.<br>&lt;entrylist&gt;<div class="im"><br>    &lt;entry type=&quot;deny&quot;&gt;<br>
        &lt;identity&gt;<br>            <span style="background-color:rgb(255,255,51)">&lt;id&gt;*&lt;/id&gt;</span><br>        &lt;/identity&gt;<br>        &lt;permissionList&gt;<br>
            &lt;permission&gt;read&lt;/permission&gt;<br>            &lt;permission&gt;write&lt;/permission&gt;            <br></div>        &lt;/permissionList&gt;                    <br>    &lt;/entry&gt;<br>    &lt;entry type=&quot;deny&quot;&gt;<br>

        &lt;identity&gt;<br>            &lt;id&gt;123&lt;/id&gt;<div class="im"><br>        &lt;/identity&gt;<br>        &lt;permissionList&gt;<br>            &lt;permission&gt;write&lt;/permission&gt;            <br></div>
        &lt;/permissionList&gt;<br>
    &lt;/entry&gt;    <br>&lt;/entrylist&gt;<br><br>There will be &#39;n&#39; number of xmls like the above in the DB. I need to retrieve the xml under two conditions.<br>1. id = 123 and entry should have read permission in the permission list<br>
<span style="background-color:rgb(255,255,153)">
2. id = * and entry should not have the read permission in it</span><br><br>I am able to form a query for the first condition. But i could not make the second condition.<br><br><br>Thanks,<br>Sudheer<div class="HOEnZb"><div class="h5">
<br><br><br><br><br><br><br><br>
<div class="gmail_quote">On Sun, Mar 25, 2012 at 9:09 AM, Damon Feldman <span dir="ltr">&lt;<a href="mailto:Damon.Feldman@marklogic.com" target="_blank">Damon.Feldman@marklogic.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Sudheer,<u></u><u></u></span></p><p class="MsoNormal">


<span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Can you post a self-contained, minimal example that runs in queryConsole? By this I mean a document insert or two and a query that shows the problem. Ideally, you would simplify the query and document to the simplest example that shows the behavior you are seeing, perhaps a single permission and two notes will work.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">This allows people to paste it into queryConsole and immediately see your problem, then try solutions.<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Yours,<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d">Damon<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1f497d"><u></u> <u></u></span></p>


<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> <a href="mailto:general-bounces@developer.marklogic.com" target="_blank">general-bounces@developer.marklogic.com</a> [mailto:<a href="mailto:general-bounces@developer.marklogic.com" target="_blank">general-bounces@developer.marklogic.com</a>] <b>On Behalf Of </b>Sudheer Yalaverthi<br>


<b>Sent:</b> Friday, March 23, 2012 4:23 PM<br><b>To:</b> MarkLogic Developer Discussion<br><b>Subject:</b> Re: [MarkLogic Dev General] Problem in making use of cts:not-query()<u></u><u></u></span></p></div><div><div></div>


<div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt">John,<br><br>i have tried this. But still this is not helping me.<br>I am putting my exact xml , scenario.<br><br>Xml in DB :<br>


<br>&lt;notelist&gt;<br>    &lt;note&gt;<br>        &lt;text&gt;this is my first note&lt;/text&gt;        <br>        &lt;accessControl&gt;<br>            &lt;explicitAccessControlList&gt;<br>                &lt;entry type=&quot;deny&quot;&gt;<br>


                    &lt;identity&gt;<br>                        &lt;id&gt;*&lt;/id&gt;<br>                    &lt;/identity&gt;<br>                    &lt;permissionList&gt;<br>                        &lt;permission&gt;read&lt;/permission&gt;<br>


                        &lt;permission&gt;write&lt;/permission&gt;<br>                        &lt;permission&gt;delete&lt;/permission&gt;<br>                        &lt;permission&gt;write-acl&lt;/permission&gt;<br>                    &lt;/permissionList&gt;                    <br>


                &lt;/entry&gt;<br>                &lt;entry type=&quot;allow&quot;&gt;<br>                    &lt;identity&gt;<br>                        &lt;id&gt;1111&lt;/id&gt;<br>                    &lt;/identity&gt;<br>


                    &lt;permissionList&gt;<br>                        &lt;permission&gt;read&lt;/permission&gt;<br>                        &lt;permission&gt;write&lt;/permission&gt;<br>                        &lt;permission&gt;delete&lt;/permission&gt;<br>


                        &lt;permission&gt;write-acl&lt;/permission&gt;<br>                    &lt;/permissionList&gt;<br>                &lt;/entry&gt;<br>            &lt;/explicitAccessControlList&gt;<br>        &lt;/accessControl&gt;<br>


    &lt;/note&gt;<br>    &lt;note&gt;<br>        &lt;note&gt;<br>            &lt;text&gt;this is my second note&lt;/text&gt;        <br>            &lt;accessControl&gt;<br>                &lt;explicitAccessControlList&gt;<br>


                    &lt;entry type=&quot;deny&quot;&gt;<br>                        &lt;identity&gt;<br>                            &lt;id&gt;*&lt;/id&gt;<br>                        &lt;/identity&gt;<br>                        &lt;permissionList&gt;<br>


                            &lt;permission&gt;write&lt;/permission&gt;<br>                            &lt;permission&gt;delete&lt;/permission&gt;<br>                        &lt;/permissionList&gt;                    <br>

                    &lt;/entry&gt;<br>
                    &lt;entry type=&quot;allow&quot;&gt;<br>                        &lt;identity&gt;<br>                            &lt;id&gt;1111&lt;/id&gt;<br>                        &lt;/identity&gt;<br>                        &lt;permissionList&gt;<br>


                            &lt;permission&gt;read&lt;/permission&gt;<br>                            &lt;permission&gt;write&lt;/permission&gt;<br>                            &lt;permission&gt;delete&lt;/permission&gt;<br>


                        &lt;/permissionList&gt;<br>                    &lt;/entry&gt;<br>                &lt;/explicitAccessControlList&gt;<br>            &lt;/accessControl&gt;<br>        &lt;/note&gt;<br>&lt;/notelist&gt;<br>


<br><br>There will be so many xmls like this in the DB. My requirement is i have to retrieve this xml if i have a note element which has my qstring in the text, and has an entry(type=allow with my id, read permission) or an entry(type= deny, id = *, should not have read permission in that).<br>


<br>Below is the query i am trying.<br><br> cts:element-query( <br>                    xs:QName(&quot;note&quot;), <br>                    cts:and-query((<br>                            cts:element-word-query( xs:QName(&quot;text&quot;), $qstring, &quot;case-insensitive&quot;),<br>


                            cts:element-query(<br>                                  xs:QName(&quot;accessControl&quot;),<br>                                  cts:element-query(<br>                                        xs:QName(&quot;explicitAccessControlList&quot;),<br>


                                        cts:or-query((                                            <br>                                            cts:element-query(<br>                                                xs:QName(&quot;entry&quot;),<br>


                                                cts:and-query((                                               <br>                                                    cts:element-query(<br>                                                        xs:QName(&quot;identity&quot;),<br>


                                                         cts:element-value-query(xs:QName(&quot;id&quot;),$user-id)<br>                                                     ),<br>                                                     cts:element-attribute-value-query(xs:QName(&quot;entry&quot;), xs:QName(&quot;type&quot;), &quot;allow&quot;) ,<br>


                                                     cts:element-value-query(xs:QName(&quot;permission&quot;),&quot;read&quot; )                                                        <br>                                                ))<br>


                                             )<br>                                             ,                                      <br>                                             cts:element-query(<br>                                                xs:QName(&quot;entry&quot;),                                                    <br>


                                                cts:and-query((<br>                                                    cts:element-query(<br>                                                        xs:QName(&quot;identity&quot;),<br>


                                                        cts:element-value-query(xs:QName(&quot;id&quot;),&quot;*&quot;)<br>                                                    ),                                                           <br>


                                                    cts:element-attribute-value-query(xs:QName(&quot;entry&quot;), xs:QName(&quot;type&quot;), &quot;deny&quot;)<br>                                                    ,                                                        <br>


                                                    cts:element-range-query(xs:QName(&quot;permission&quot;), &quot;!=&quot;, &quot;read&quot;, &quot;collation=<a href="http://marklogic.com/collation/" target="_blank">http://marklogic.com/collation/</a>&quot; )                                                           <br>


                                                ))<br>                                             )                                            <br>                                        ))<br>                                  )<br>


                            )<br>                    ))<br>              )<br><br><br>I am still not able to get the expected results. :(<br><br><br><br>Thanks,<br>Sudheer <u></u><u></u></p><div><p class="MsoNormal">On Fri, Mar 23, 2012 at 12:48 PM, John Zhong &lt;<a href="mailto:john@yuxipacific.com" target="_blank">john@yuxipacific.com</a>&gt; wrote:<u></u><u></u></p>


<p class="MsoNormal">You can change your cts:not-query(cts:element-value-query(xs:QName(&quot;subject&quot;), &quot;C&quot;)) to cts:element-range-query(xs:QName(&quot;subject&quot;), &quot;!=&quot;,&quot;C&quot;), which needs the &quot;Element Range Indexes&quot; on subject element.<br>


<br>So,<u></u><u></u></p><div><p class="MsoNormal"><br><br>cts:element-query(<br>      xs:QName(&quot;user&quot;),<br>      cts:and-query((<br>        cts:element-value-query(xs:QName(&quot;id&quot;), &quot;222&quot;),<br>


        cts:element-attribute-value-query(xs:QName(&quot;user&quot;), xs:QName(&quot;branch&quot;), &quot;CSE&quot;),<u></u><u></u></p></div><p class="MsoNormal" style="margin-bottom:12.0pt">        cts:element-range-query(xs:QName(&quot;subject&quot;), &quot;!=&quot;,&quot;C&quot;)<br>


      ))<br>)<br><br>It worked for me on ML 4.2 version.<br><br>The cts:not-query does not work, in my opinion, it is because:<br><br>In your sample XML:<br><br>/userdetails//subject = &quot;C&quot;<br>&gt; true<br><br>not(/userdetails//subject = &quot;C&quot;)<br>


&gt; false<br><br>So, I think the cts:not-query works similarly...<br><br>BTW, I tried the solution mentioned by Geert, to define the user as fragment root, but it did not work.<br><br>John<u></u><u></u></p><div><div><div>


<p class="MsoNormal">On Fri, Mar 23, 2012 at 4:48 AM, Sudheer Yalaverthi &lt;<a href="mailto:sudheer.yalaverthi@gmail.com" target="_blank">sudheer.yalaverthi@gmail.com</a>&gt; wrote:<u></u><u></u></p></div></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">


<div><div><p class="MsoNormal" style="margin-bottom:12.0pt">Hi Team,<br><br>My sample XML would be like this.<br><br>&lt;userdetails&gt;<br>    &lt;user branch=&quot;CSE&quot;&gt;<br>        &lt;id&gt;111&lt;/id&gt;<br>        &lt;subjectList&gt;<br>


            &lt;subject&gt;C&lt;/subject&gt;<br>            &lt;subject&gt;C++&lt;/subject&gt;<br>            &lt;subject&gt;Oracle&lt;/subject&gt;<br>        &lt;/subjectList&gt;<br>    &lt;/user&gt;<br>    &lt;user branch=&quot;CSE&quot;&gt;<br>


        &lt;id&gt;222&lt;/id&gt;<br>        &lt;subjectList&gt;            <br>            &lt;subject&gt;C++&lt;/subject&gt;<br>            &lt;subject&gt;Oracle&lt;/subject&gt;<br>        &lt;/subjectList&gt;<br>    &lt;/user&gt;<br>


    &lt;user branch=&quot;IT&quot;&gt;<br>        &lt;id&gt;333&lt;/id&gt;<br>        &lt;subjectList&gt;<br>            &lt;subject&gt;C&lt;/subject&gt;<br>            &lt;subject&gt;C++&lt;/subject&gt;<br>            &lt;subject&gt;Oracle&lt;/subject&gt;<br>


        &lt;/subjectList&gt;<br>    &lt;/user&gt;<br>&lt;/userdetails&gt;<br><br><br>I have a requirement where i should pick this Xml from the DB if there is a user entry with branch as&quot;CSE&quot; and id =222 and it should not have &quot;C&quot; as subject.<br>


<br>If i write a additional query something like below for search:search()<br>cts:element-query(<br>      xs:QName(&quot;user&quot;), <br>      cts:and-query((<br>      cts:element-value-query(xs:QName(&quot;id&quot;), &quot;222&quot;),<br>


      cts:element-attribute-value-query(xs:QName(&quot;user&quot;), xs:QName(&quot;branch&quot;), &quot;CSE&quot;),<br>      cts:not-query(cts:element-value-query(xs:QName(&quot;subject&quot;), &quot;C&quot;))<br>      ))<br>


)<br><br>This is not turning me up the results. The only one scenario this query is gonna return back the result is if none of the users in the DB has the subject as &quot;C&quot;. but this is not i am expecting. I know there is one user element which satisfies all the conditions and other user elements which fail these connditions. I want to retrieve the Xml even if one of the user element passes all these conditions irrespective of other elements pass or fail. Please suggest me.<br>


I am using search:search and i can not avoid this as i have some other requirements to sorting the result Xmls.<br><br><br>Thanks, <br><span style="color:#888888">Sudheer <br><br></span><u></u><u></u></p></div></div><p class="MsoNormal" style="margin-bottom:12.0pt">


_______________________________________________<br>General mailing list<br><a href="mailto:General@developer.marklogic.com" target="_blank">General@developer.marklogic.com</a><br><a href="http://developer.marklogic.com/mailman/listinfo/general" target="_blank">http://developer.marklogic.com/mailman/listinfo/general</a><u></u><u></u></p>


</blockquote></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br><br>_______________________________________________<br>General mailing list<br><a href="mailto:General@developer.marklogic.com" target="_blank">General@developer.marklogic.com</a><br>


<a href="http://developer.marklogic.com/mailman/listinfo/general" target="_blank">http://developer.marklogic.com/mailman/listinfo/general</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div>


</div><br>_______________________________________________<br>
General mailing list<br>
<a href="mailto:General@developer.marklogic.com" target="_blank">General@developer.marklogic.com</a><br>
<a href="http://developer.marklogic.com/mailman/listinfo/general" target="_blank">http://developer.marklogic.com/mailman/listinfo/general</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
General mailing list<br>
<a href="mailto:General@developer.marklogic.com">General@developer.marklogic.com</a><br>
<a href="http://developer.marklogic.com/mailman/listinfo/general" target="_blank">http://developer.marklogic.com/mailman/listinfo/general</a><br>
<br></blockquote></div><br></div>