You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Upayavira <uv...@upaya.co.uk> on 2004/01/13 13:43:45 UTC

Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Ugo Cei wrote:

> upayavira@apache.org wrote:
>
>> upayavira    2004/01/13 00:44:05
>>
>>   Modified:    
>> src/blocks/xmldb/java/org/apache/cocoon/components/source/impl
>>                         XMLDBSource.java
>>   Log:
>>   Making XMLDBSource modifiable. Should be useful with Woody binding 
>> infrastructure, and can use SourceWritingTransformer to write to DB 
>> (as well as XMLDBTransformer)
>
>
> You are my hero! I'm going to use this in a few minutes :-).

Great. Things to note:

I've currently implemented it so that, if the URL of a source ends with 
a / (i.e. refers to a collection), a new document will be inserted into 
the collection with a name created by the database, and the URL of the 
source will be changed to include the new document name. For this latter 
bit, see my trivial recent commit.

Also, it can currently only write at a document level. I'm sure it would 
be possible to write using xupdate or some such, but seeing as I don't 
know them yet, I'll leave that for someone else or some other time.

Regards, Upayavira



Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Upayavira <uv...@upaya.co.uk>.
Ugo Cei wrote:

> It looks like we might have a problem. I copied the loadDocument 
> function from woody's binding_example.js and passed it an "xmldb:" 
> URI. This is the exception I get when I call
>
> var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
>
> org.apache.cocoon.CascadingIOException: Could not lookup pipeline 
> components: org.apache.avalon.framework.service.ServiceException: 
> Could not find component (key 
> [org.apache.cocoon.serialization.SerializerSelector]) 
> (Key='org.apache.cocoon.serialization.SerializerSelector')

But that's not in my new code, that is in the unchanged 
getInputStream(), which uses an XML serializer to serialize SAX events. 
Why it shouldn't be able to get a SerializerSelector I don't know, but 
I'm not an Avalon guru.

Regards, Upayavira



Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Upayavira <uv...@upaya.co.uk>.
Ugo Cei wrote:

> It looks like we might have a problem. I copied the loadDocument 
> function from woody's binding_example.js and passed it an "xmldb:" 
> URI. This is the exception I get when I call
>
> var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
>
> org.apache.cocoon.CascadingIOException: Could not lookup pipeline 
> components: org.apache.avalon.framework.service.ServiceException: 
> Could not find component (key 
> [org.apache.cocoon.serialization.SerializerSelector]) 
> (Key='org.apache.cocoon.serialization.SerializerSelector')

I've just got this now.

Don't know why a source can't get a SerializerSelector when called from 
flow. Anyway I propose to change the source to use trax to serialize, 
rarher than a serializer. Any objections?

Regards, Upayavira



Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Ugo Cei <u....@cbim.it>.
Guido Casper wrote:
> SourceUtil.toDOM() uses the same code, but calls source.toSAX() only if
> it exists (i.e. the source implements XMLizable). If not, SourceUtil
> falls back to using the XMLizer (which in turn calls
> source.getInputStream again). So SourceUtil works with any kind of
> source while your code does only work on sources implementing XMLizable.

Aw, cool! Thank you.

	Ugo


Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Guido Casper <gc...@s-und-n.de>.
Ugo Cei wrote:
> Guido Casper wrote:
>> I have no idea what the reason might be but maybe you want to try:
>> org.apache.cocoon.components.source.SourceUtil.toDOM(source);
>
> I already found a workaround:
>
> var domBuilder = new Packages.org.apache.cocoon.xml.dom.DOMBuilder();
> source.toSAX(domBuilder);
> return domBuilder.document;
>
> (BTW, what's the difference between my version and yours?)

SourceUtil.toDOM() uses the same code, but calls source.toSAX() only if
it exists (i.e. the source implements XMLizable). If not, SourceUtil
falls back to using the XMLizer (which in turn calls
source.getInputStream again). So SourceUtil works with any kind of
source while your code does only work on sources implementing XMLizable.

Guido


Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Ugo Cei <u....@cbim.it>.
Guido Casper wrote:
> I have no idea what the reason might be but maybe you want to try:
> org.apache.cocoon.components.source.SourceUtil.toDOM(source);

I already found a workaround:

var domBuilder = new Packages.org.apache.cocoon.xml.dom.DOMBuilder();
source.toSAX(domBuilder);
return domBuilder.document;

(BTW, what's the difference between my version and yours?)

but I don't have time to dig deeper into the problem ATM and just wanted 
to let it be known. Maybe it's just my installation. Can anyone else 
confirm it?

	Ugo




Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Guido Casper <gc...@s-und-n.de>.
Ugo Cei wrote:
> It looks like we might have a problem. I copied the loadDocument
> function from woody's binding_example.js and passed it an "xmldb:"
> URI. This is the exception I get when I call
> 
> var is = new
> Packages.org.xml.sax.InputSource(source.getInputStream()); 
> 
> org.apache.cocoon.CascadingIOException: Could not lookup pipeline
> components: org.apache.avalon.framework.service.ServiceException:
> Could not find component (key
> [org.apache.cocoon.serialization.SerializerSelector])
> (Key='org.apache.cocoon.serialization.SerializerSelector')

I have no idea what the reason might be but maybe you want to try:
org.apache.cocoon.components.source.SourceUtil.toDOM(source);

instead.

HTH
Guido

Re: cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl

Posted by Ugo Cei <u....@cbim.it>.
It looks like we might have a problem. I copied the loadDocument 
function from woody's binding_example.js and passed it an "xmldb:" URI. 
This is the exception I get when I call

var is = new Packages.org.xml.sax.InputSource(source.getInputStream());

org.apache.cocoon.CascadingIOException: Could not lookup pipeline 
components: org.apache.avalon.framework.service.ServiceException: Could 
not find component (key 
[org.apache.cocoon.serialization.SerializerSelector]) 
(Key='org.apache.cocoon.serialization.SerializerSelector')

	Ugo