[MarkLogic Dev General] element queries

Krokowski.Todd krokowski.todd at ensco.com
Tue May 27 07:43:17 PDT 2008


This was discussion was very useful, I also hope the enhancement request
makes it into a future release! We would really like to use an element's
attributes in a cts:element-query instead of having to rely on multiple
element types.

Todd Krokowski
Senior Solutions Engineer
-------------------------------
ENSCO ENDATA
44 Dalliba Ave.
Watervliet, NY 12189
Desk: 518.266.6047
Mobile: 518.577.9948

-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Shannon
Scott Shiflett
Sent: Friday, May 23, 2008 3:21 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] element queries

Mike, I was referring to the example given in the function  
documentation for cts:element-attribute-value-query(), but you are  
right, that is not exactly what I was looking for.  The solution you  
provide is indeed good enough, thanks.  I hope your enhancement  
request to have cts:element-query include its own attributes is  
accepted.

On May 22, 2008, at 5:00 PM, Mike Sokolov wrote:

> That won't even do what you want, I don't think.
>
> Try this mysterious exercise:
>
> xdmp:document-insert ("/a",
> <a type="one">
> matching text
> </a>);
>
> cts:search (//a, cts:element-query(xs:QName("a"),
>        cts:and-query((
>                       cts:element-attribute-value- 
> query(xs:QName("a"), xs:QName("type"), "one"),
>                       "matching text" )) )
>
> => get empty result set
>
> I have had a request in for a while to allow cts:element-query to  
> include its own attributes, but at the moment at least, it doesn't.
>
> You might find this good enough:
> cts:and-query((
>                      cts:element-attribute-value- 
> query(xs:QName("a"), xs:QName("type"), "one"),
>                       "matching text" ))
>
> although the semantics are not the same as:
>
> //a[@type="one"][contains(., "matching text")]
>
> because the matching text could appear in some outer a node as in:
>
> <a type="two"> matching text
> <a type="one">
> no match
> </a></a>
>
>
> You might want to fiddle around with fields: if you can burn in the  
> attribute value constraint by defining an index I think there is a  
> way to to this using a field.
>
> -Mike
>
>
> Shannon Scott Shiflett wrote:
>> hi hi,
>>
>> is the only way to do a cts:element-query() on elements by name  
>> with attribute by name with "text content equal to given phrase" by  
>> wrapping a cts:element-query() and a cts:element-attribute-value- 
>> query() in a cts:and-query()?  wondering if there is a way  
>> requiring fewer lines of xquery.
>>
>> thank you,
>> shannon
>> _______________________________________________
>> General mailing list
>> General at developer.marklogic.com
>> http://xqzone.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general

_______________________________________________
General mailing list
General at developer.marklogic.com
http://xqzone.com/mailman/listinfo/general

......................................................................
The information contained in this email message is intended only for the use of the individuals to whom it is
addressed and may contain information that is privileged and sensitive. If the reader of this message is not
the intended recipient, you are hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this communication in error, please notify the
sender immediately by email at the above referenced address. Thank you.


More information about the General mailing list