The following works perfectly in CQ: for $a in distinct-values(//a/b) let $c := //c[d = $a]/descendant::era:e order by $a return <tr> <td>{$a}</td> <td>{$c}/></td> </tr>
The same query in stored XQuery gives an error "Expression depends on the context where none is defined". I have tried multiple XPath approaches but I haven't been able to get the XPath statement to move above the currently document in the collection: for $a in distinct-values(collection()/a/b) let $c := $a/ancestor::a/../descendant::c[d = $a]/descendant::era:e order by $a return <tr> <td>{$a}</td> <td>{$c}/></td> </tr> What is the best approach for doing joins within MarkLogic within a collection? It is probably something really simple that I am not finding. TIA! Betty /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Betty Harvey | Phone: 410-787-9200 FAX: 9830 Electronic Commerce Connection, Inc. | har...@eccnet.com | Washington,DC XML Users Grp URL: http://www.eccnet.com | http://www.eccnet.com/xmlug /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\\/\/ Member of XML Guild (www.xmlguild.org) _______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general