Thanks Danny. What I'm mainly trying to do is speed up some slow xpath. I've optimized a lot of this module, but this xpath seems to be one of the remaining bottlenecks: //(a|b|c|d|e|f|g)[@foo = "bar"]. I thought that by converting it to a cts:query it would be faster. Or is this Xpath already going to be optimized by MLS?
-Will -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Danny Sokolsky Sent: Wednesday, July 27, 2011 5:20 PM To: General MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] xpath to cts query question Hi Will, I might not be understanding what you are doing here, but here are a few ideas. I think you can use that XPath in the first arg of cts:search, as long as you do not put any variables in it. Something like this: cts:search(//(a|b|c|d|e|f|g)[@foo = "bar"], "hello") Also, in cts:query, you can do a cts:element-query with the cts:element-attribute-query as its second arg. Something like: cts:element-query((xs:QName("a"), xs:QName("b")), cts:element-attribute-word-query((xs:QName("a"), xs:QName("b")), xs:QName("foo"), "bar")) -Danny -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Will Thompson Sent: Wednesday, July 27, 2011 2:51 PM To: General MarkLogic Developer Discussion Subject: [MarkLogic Dev General] xpath to cts query question I'm trying to create the cts equivalent of essentially this: //(a|b|c|d|e|f|g)[@attr = $val] But it seems like I would have join multiple cts:search()s, one for each element, since I only want the matching element, and not its parent (so I can't do something like cts:search(//(a|b|c|d|e|f|g), cts:element-attribute-value-query((xs:QName("a"),...,(xs:QName("g")),xs:QName("attr"),$val)). cts:search(//a, cts:element-attribute-value-query(xs:QName("a"),xs:QName("attr"),$val)) | cts:search(//b, cts:element-attribute-value-query(xs:QName("b"),xs:QName("attr"),$val)) | cts:search(//c, cts:element-attribute-value-query(xs:QName("c"),xs:QName("attr"),$val)) ... | cts:search(//g, cts:element-attribute-value-query(xs:QName("g"),xs:QName("attr"),$val)) Is there a better way to do this? Thank you! -Will _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
