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
> http://developer.marklogic.com/mailman/listinfo/general

_______________________________________________
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to