Hi,

Try this ,

cts:search(/root/child1/child2,
  cts:and-query((
    cts:element-attribute-value-query(xs:QName("child2"), xs:QName("att"), "1"),
    cts:element-attribute-value-query(xs:QName("child3"), xs:QName("att"), "1")
    )))/child3[@att = "1"]

Thanks and regards
Raja >>>

From: [email protected] 
[mailto:[email protected]] On Behalf Of ???
Sent: Friday, July 10, 2015 1:40 PM
To: [email protected]
Subject: [MarkLogic Dev General] Equivalent conversion from Xquery to 
cts:queries

In my database, the most of xml documents content likes this:
<root>
            <child1 att="1">
                        <child2 att="1" id="1">
                                    <child3 att="1" id="1">
                                    </child3>
                                    <child3 att="2" id="2">
                                    </child3>
                        </child2>
                        <child2 att="1" id="2">
                                    <child3 att="3">
                                    </child3>
                        </child2>
            </child1>
</root>

the Xquery is:
for $i in collection()/root/child1/child2/child3
where
$i/@att = '1'
and $i/..[@att] = '1'
return $i/@id
and its result is:
<child3 att="1" id="1"> </child3>

but when i use the cts:query to do the same thing , the result is different

query :
cts:search(collection()/root/child1/child2,
  cts:and-query((
    cts:element-attribute-value-query(xs:QName("child2"), xs:QName("att"), "1"),
    cts:element-attribute-value-query(xs:QName("child3"), xs:QName("att"), "1")
    )))/child3
and result is:
<child3 att="1" id="1"></child3>
element <http://172.18.34.28:8000/qconsole/>
<child3 att="2" id="2"></child3>

so how can i rewrite the XQuery by useing cts:queries when ../ appear in the 
where condition?

This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to