Ronald Bourret wrote: 
> I'm coming at this as a naive user, but I think of collections the same
> way I think of directories in a file system -- a way to organize things
> by topic, not by file type. For example, if I have an XML document that
> references an unparsed entity, I expect to store the XML document and
> the unparsed entity in the same collection.
> 
> Are collections closer to tables? That is, a set of things that share
> the same schema? If so, what are the end user benefits of this? Do I get
> automatic schema validation? Automatic indexing? etc.

Which is true is going to depend completely on the product. Both
currently exist and fall under the category of XML database. So given
that you're probably right.

This is good though I didn't really like the way resources work right
now anyway. :-)

How about this.

interface Resource {       
   Collection getParentCollection();       
   string getId();
   string getResourceType();

   void setContent(Object content);
   Object getContent();
}; 


interface XMLResource : Resource {
   // Default getContent/setContent from Resource returns text

   // DOM Support
   Node getContentAsDOM();
   void setContentAsDOM(Node content);

   // SAX Support
   void getContentAsSAX(in ContentHandler handler);
   ContentHandler setContentAsSAX();   
}

interface BinaryResource : Resource {
   // Simply overrides getContent/setContent from Resource
}

This gets rid of the setting of ResourceType on collection which is the
one thing that really bugged me about the current API. The database can
determine the type of resource to return seamlessly and the client can
just use it how it wants. Also if the database doesn't support either
DOM or SAX the API on the client can always parse the text document
easily into either format and communicate with the server in whatever
format it expects.

Usage in Java would look like.

Collection collection = DatabaseManager.getCollection("some db uri");

String id = "gladiator-2000";
Resource res = collection.getResource(id);
if ((res.getType()).equals("XMLResource")) {
   XMLResource resource = (XMLResource) res;
   Document doc = res.getContentAsDOM();
   // or could be
   String text = (String) res.getContent();
}
else if ((res.getType()).equals("BinaryResource")) {
   BinaryResource resource = (BinaryResource) res;
   OutputStream content = (OutputStream)res.getContent();
}

If you're just working with XML which I'd think would be a far more
common case it would just look like this which is pretty clean (sans
error handling anyway).

Collection collection = DatabaseManager.getCollection("some db uri");

String id = "gladiator-2000";
XMLResource res = (XMLResource) collection.getResource(id);
Document doc = res.getContentAsDOM();



> 
> -- Ron
> 
> ----------------------------------------------------------------------
> Post a message:         mailto:[EMAIL PROTECTED]
> Unsubscribe:            mailto:[EMAIL PROTECTED]
> Contact adminstrator:   mailto:[EMAIL PROTECTED]
> Read archived messages: http://archive.xmldb.org/
> ----------------------------------------------------------------------

-- 
Kimbro Staken
Chief Technology Officer
dbXML Group L.L.C
http://www.dbxmlgroup.com

----------------------------------------------------------------------
Post a message:         mailto:[EMAIL PROTECTED]
Unsubscribe:            mailto:[EMAIL PROTECTED]
Contact adminstrator:   mailto:[EMAIL PROTECTED]
Read archived messages: http://archive.xmldb.org/
----------------------------------------------------------------------

Reply via email to