[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with OzoenEnv.bat and some XML:DB questions



Per Nyfelt wrote:
> 
> In org.xmldb.api.modules.XMLResource the getter and setter for SAX is
> flipped
>         void getContentAsSAX( ContentHandler handler ) throws XMLDBException;
> should be
>         void setContentAsSAX( ContentHandler handler ) throws XMLDBException;
> and
>         ContentHandler setContentAsSAX() throws XMLDBException; should be
>         ContentHandler getContentAsSAX() throws XMLDBException;
> 

Even though it seems wrong the API is actually correct. When you want to
retrieve content from the API as a SAX event stream you want to provide
your own ContentHandler implementation to do your application specific
processing of the content. This is why getContentAsSAX takes a
ContentHandler as a parameter. The implementation uses that
ContentHandler, which is your own implementation, to parse the XML. 

For setting content you need to retrieve a content handler from the the
API that knows how to store the SAX event stream to the database. You
can then use that ContentHandler as part of your application specific
SAX parse to store XML content into the database. 


> The org.ozoneDB.xml.cli.resources.XMLResourceImpl should be changed
> accordingly.
> 
> What happened to org.xmldb.api.modules.SAXResource and
> org.xmldb.api.modules.DOMNodeResource? In the use case description they had

These have been merged into XMLResource. The use case would now look
more like.

XMLResource resource = (XMLResource) collection.getResource(id);
Document doc = (Document) resource.getContentAsDOM();

The UseCases document that is on the web site is a little out of date
compared to the current IDL and Java interfaces. If you work off the
Java interfaces from the XML:DB CVS server then you'll get the most
current version of the API but it might not match what is published on
the site. The site will be updated shortly to bring it back into sync
with CVS. However, as the API evolves what is published on the site is
always going to lag behind what is in CVS. Since this API is still
evolving it would be a really good idea to join the xapi-dev@xmldb.org
mailing list so you can contribute feedback and keep informed of the
changes. 

> the idea of doing:
>         DOMNodeResource resource = (DOMNodeResource) uc.collection.getResource(id);
>         Document doc = (Document) resource.getContent();
> 
> but since DOMNodeResource is gone how are you supposed to do to get a
> org.w3c.dom.Document?
> 
> For SAX, what about:
>         SAXResource resource = (SAXResource) collection.getResource(id);
>         ContentHandler handler = new MyContentHandler();
>         resource.setContentHandler(handler);
> 
> with SAXResource gone are you supposed to now do something like:
>         XMLResource resource = (XMLResource) collection.getResource(id);
>         ContentHandler handler = new MyContentHandler();
>         resource.setContentAsSAX(handler);

For SAX it would be.

XMLResource resource = (XMLResource) collection.getResource(id);
ContentHandler handler = new MyContentHandler();
resource.getContentAsSAX(handler);

> ?
> 
> Best regards,
> Per

-- 
Kimbro Staken
The dbXML Project
http://www.dbxml.org/