[MarkLogic Dev General] search elements and attributes of
Pradeep.Maddireddy at HTCinc.com
Tue Dec 30 14:28:48 PST 2008
The XML documents in my case can have different structures so I will not
know the element name or attribute name to use in the function
From: Danny Sokolsky [mailto:dsokolsky at marklogic.com]
Sent: Tuesday, December 30, 2008 5:23 PM
To: Pradeep Maddireddy; General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] search elements and attributes of
You can do a cts:search with a cts:word-query to find the text in text
nodes in your document, which will take care of your Doc1 case,
regardless of what element the text is in. For the Doc2 case, you need
to use a cts:element-attribute-word-query and specify the element and
attribute. For the attributes, you need to specify each
element-attribute pair that you want to search through. If you combine
the 2 queries with an or-query, then you can search for them both at the
same time. Something like:
let $word := "apple"
cts:search(doc(), cts:or-query(( cts:word-query($word),
xs:QName("category"), $word) )) )
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Pradeep
Sent: Tuesday, December 30, 2008 1:57 PM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] search elements and attributes of
How can we write an Xquery function to find the documents (XML documents
with different structures) that have the word "fruit" in them either as
an element or attribute?
For example say Doc1 has the following content
Doc2 has the following content
Both the documents should be selected as the first document has "fruit"
as element and second document has "fruit" as an attribute.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the General