[Yanel-dev] New XMLDB repository

Andreas Wuest awuest at student.ethz.ch
Fri Feb 9 17:01:58 CET 2007


Hi

I've finished and checked in a basic implementation of the XMLDB 
repository, based on the XML:DB API.

Unfortunately, Yarep is documented really bad, so I couldn't find out 
what the exact contracts for the various methods are. For example, 
should getSize() or delete() throw a repository exception if the 
resource does not exist, or return 0 or false, etc.

I've extensively documented the XMLDBStorage class, so you can see what 
it does on the first glance.

The Reader/Writer and InputStream/OutputStream are implemented using 
aggregation. Don't know if it would be more desireable to e.g. subclass 
StringReader and override the close() method instead.

Also, there are some other API related problems: Yanel always seems to 
call getInputStream to directly read from the repo. Now, this is all 
fine and dandy on a file based repo, but the XML database stores XML 
documents as character data, and returns them as strings. With other 
words, in order for the OutputStream to work, we have to convert the 
string to bytes, which, of course, involves character encoding. I just 
use UTF-8 to de- and encode, but of you really want to read an XML 
resource, the getReader method should be used.

The same goes for writing, but with some additional complication. You 
should NEVER use getOutputStream to write an XML document. 
getOutputStream creates a binary resource in the database. Use getWriter 
instead to write character data, which creates an XML resource.

I could also do with some testing ;) (I plan on eventually write some 
tests, but didn't have the time yet, the repo has to be finished by 
monday for our Annotations project).

-- 
Kind regards,
Andi



More information about the Yanel-development mailing list