you can use an xpath:
 
/html/body/[EMAIL PROTECTED]"atval11" and @attr2="atval12"]
 
that will actually return the individual matching elements.  changing
the predicate can change what is returned.
 
you can use a search:
 
cts:search(/html,
cts:and-query((cts:element-attribute-value-query(xs:QName("element"),
xs:QName("attr1"),
"atval11"),cts:element-attribute-value-query(xs:QName("element"),
xs:QName("attr2"), "atval12"))))
 
with the slight caveat that as written, this will not insist that the
attr1 and attr2 attributes have the same element parent.
 
in both cases, you need to watch out for namespaces.  these queries will
match the xml you have provided, but the xml you have provided is not in
the xhtml namespace, which yours may well be.  generally the reason for
xpaths or cts:search() not matching something that it seems like it
should match is namespace mismatches...
 
ian

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Devadoss P
Sent: Friday, August 10, 2007 5:11 AM
To: [email protected]
Subject: [MarkLogic Dev General] Attribute value based xquery


Hi,
 
I am having problem in generating xquery to search on attribute value of
html element.  Can anyone comeacross this situation?
 
<html>
<body>
<element1 attr1="atval11" attr2="val12" />
<element1 attr1="atval21" attr2="val22" />
<element1 attr1="atval31" attr2="val32" />
<element1 attr1="atval41" attr2="val42" />
</body>
</html> 
 
I want to get documents that satisfy "attr1" value = "atval11" and
attr2="val12".
 
I used cts;element-attribute-value-query but it doesn't return expected
value for html documents.
 
Appreciate your feedback,
 
~Dev~
 
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to