The code context is CQ - so I don't think there is a default namespace. I am just entering xquery through CQ.
Can you help me understand how to tell if that is indeed the problem, and what to do to get around it? From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Jason Hunter Sent: Thursday, August 18, 2011 2:43 PM To: General MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] Querying across multiple documets loaded into a collection My guess is namespaces. In the code context where you're doing /testreport I bet you have a default element namespace which is implicitly requiring <testreport> be in that namespace. -jh- On Aug 18, 2011, at 11:40 AM, Zegarek, Arthur wrote: Load 2 small xml documents into a collection, and would like to be able to write an xquery that scans across all documents without naming them Example: Doc 1 contains: <testreport><report><filename>abc</filename></report></testreport> Doc 2 contains: <testreport><report><filename>xyz</filename></report></testreport> Load each file as follows: Doc 1: xdmp:document-load("/opt/home/testreport1.xml", <options xmlns="xdmp:document-load"> <uri>testreport1</uri> <collections> <collection>TESTDOCS</collection> </collections> </options>) Doc 2: xdmp:document-load("/opt/home/testreport2.xml", <options xmlns="xdmp:document-load"> <uri>testreport2</uri> <collections> <collection>TESTDOCS</collection> </collections> </options>) Run this xquery: for $test in collection("TESTDOCS") return $test Results: <testreport><report><filename>abc</filename></report></testreport> <testreport><report><filename>xyz</filename></report></testreport> But run this xquery: for $test in collection("TESTDOCS")/testreport return $test Results: Empty Also tried with // and testreport[1] I know this can be done, but I'm not clear on what is missing/incorrect from this simple example. Thanks in advance assistance. Art _______________________________________________ General mailing list General@developer.marklogic.com<mailto:General@developer.marklogic.com> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list General@developer.marklogic.com http://developer.marklogic.com/mailman/listinfo/general