Awesome, that works perfectly, thanks!

I do have a question though.  How come one must use a loop in order to access elements in this way?  It seems like the names of the documents in a database would be a sort of key that would allow constant time look ups, being that they must be unique.  Especially since the hierarchy is there conceptually: database -> document -> root node -> children, so it's strange that something like: collection("db")/document("document-name")/root/child is not possible.

--
Ryan Lewis '09
Clarkson University


On Thu, Jul 29, 2010 at 11:42 AM, Michael Seiferle <michael.seiferle@uni-konstanz.de> wrote:
Hi Ryan,
sorry for misleading you, I was tricked by our commands myself.
Instead of basex:db('name') which opens the DB as a database (thus the first document is added to the context) please use the collection('name') command:
> for $doc in collection('test')
> return $doc
Sorry for the inconvenience, the hint on using matches(document-uri(... should work correctly now.
If you have any further questions feel free to ask.
Kind regards
Michael


Am 29.07.2010 um 16:57 schrieb Ryan Lewis:

> Hey,
>
> Thanks for the quick reply!
>
> I decided to do a simple query using basex:db(), and its results are... odd. Simply performing:
>> for $doc in basex:db('yourdb')
>> return $doc
> only returns the first document in my database.  I thought maybe the database was corrupt or something, so I tried:
>> for $doc in /my_root_node
>> return $doc
> And that returned the entire structure of all documents in the database.
>
> Is that the normal functionality of basex:db()?  If so, then I can not iterate through it as per your examples, since it will only see the first document.
>
> --
> Ryan Lewis '09
> Clarkson University
>
>
> On Thu, Jul 29, 2010 at 10:42 AM, Michael Seiferle <michael.seiferle@uni-konstanz.de> wrote:
> Hi there,
>
> the most convenient way to identify documents inside collections might be restricting the the query to a single document or a group of documents via matching the document-uri()
>> for $doc in basex:db('yourdb')
>>      where matches(document-uri($doc),'test.xml')
>> return $doc
> Please note that the document-uri() function only evaluates document-nodes, to test against inner nodes you should use
> base-uri($node) instead of document-uri():
>
>> for $node in basex:db('yourdb')//child
>>      where matches(base-uri($node),'test.xml')
>> return $node
>
> As there is no standardized way of handling collections of XML documents we are still looking forward to feedback regarding this issue.
>
> Hope this helps, feel free to ask more otherwise.
>
> Kind regards
> Michael
>
> Am 29.07.2010 um 16:29 schrieb cosmotron+basex@gmail.com:
>
>> If I add two documents to a BaseX DB, let's say normal.xml and normal2.xml, is there a way to refer to each one individually?
>>
>> I know about the doc() function, but it looks at the filesystem for their location, rather than in the database itself.
>>
>> For instance, if I query with this: doc("normal.xml")/name , then I will get an error about normal.xml not being found.
>>
>> I also tried: basex:db("my-db-name")/doc("normal.xml")/name and received the same error.
>>
>> Thanks for any help!
>>
>> _______________________________________________
>> BaseX-Talk mailing list
>> BaseX-Talk@mailman.uni-konstanz.de
>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
>