You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Timur Izhbulatov <ti...@yxo.ru> on 2004/05/17 15:37:44 UTC

[SOLVED] Binding to xmldb

Timur Izhbulatov wrote: 

> Hi all!  
> 
> I use woody binding framework as shown in the corresponding sample (cocoon 
> 2.1.4) with an XML file and it works just fine. But when I change the file 
> URL to xmldb one my non-us (UTF-8 encoded) data are getting corrupted. 
> When I popultate the DB with the same data (as in xmldb sample) it also 
> works correctly.  
> 
> My sitemap entry looks as follow:
> ...
>   <map:match pattern="edit">
>      <map:call function="woody">
>        <map:parameter name="function" value="form2xml"/>
>      <map:parameter name="form-definition" value="forms/form_model.xml"/>
> 	 <map:parameter name="documentURI"
> 	     value="data/1.xml"/>
> 	 <!-- <map:parameter name="documentURI"
> 	     value="xmldb:xindice-embed:///db/data/1"/> -->
>        <map:parameter name="bindingURI" value="forms/form_bind.xml"/>
>      </map:call>
>    </map:match>
> ...  
> 
> The form2xml function was totally borrowed from binding_example.js. Should 
> I rewrite my flow script or somehow configure the database operation? 

I changed the 
org.apache.cocoon.components.source.impl.XMLDBSource.XMLDBOutputStream.close 
() method:
       public void close() throws IOException, SourceException {
           if (!isClosed) {
               writeOutputStream(baos.toString("UTF-8"));
               baos.close();
               this.isClosed = true;
           }
       }
It used to use baos.toString() but this method uses system's default 
encoding (windows-1251 in my case) to translate bytes into characters 
(http://java.sun.com/j2se/1.4.2/docs/api/java/io/ByteArrayOutputStream.html) 
. 

 

Timur 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Binding to xmldb

Posted by Timur Izhbulatov <ti...@yxo.ru>.
Upayavira wrote: 

>> I agree with you. I think there should be a property in the XMLDBSource 
>> class that sets the encoding and the system's default encoding should 
>> still be used by default.
> 
> So are you offering to create a patch? ;-)

I'm just sharing my suggestions. 

BTW, I have submited this bug to Bugzilla.
I'll try to crteate a patch for this, but I'm not a Java programmer, 
unfortunately. 

Timur 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Binding to xmldb

Posted by Upayavira <uv...@upaya.co.uk>.
Timur Izhbulatov wrote:

> Upayavira писал(а):
>
>> Timur Izhbulatov wrote:
>>
>>> Timur Izhbulatov wrote:
>>>
>>>> Hi all! I use woody binding framework as shown in the corresponding 
>>>> sample (cocoon 2.1.4) with an XML file and it works just fine. But 
>>>> when I change the file URL to xmldb one my non-us (UTF-8 encoded) 
>>>> data are getting corrupted. When I popultate the DB with the same 
>>>> data (as in xmldb sample) it also works correctly. My sitemap entry 
>>>> looks as follow:
>>>> ...
>>>>   <map:match pattern="edit">
>>>>      <map:call function="woody">
>>>>        <map:parameter name="function" value="form2xml"/>
>>>>      <map:parameter name="form-definition" 
>>>> value="forms/form_model.xml"/>
>>>>      <map:parameter name="documentURI"
>>>>          value="data/1.xml"/>
>>>>      <!-- <map:parameter name="documentURI"
>>>>          value="xmldb:xindice-embed:///db/data/1"/> -->
>>>>        <map:parameter name="bindingURI" value="forms/form_bind.xml"/>
>>>>      </map:call>
>>>>    </map:match>
>>>> ... The form2xml function was totally borrowed from 
>>>> binding_example.js. Should I rewrite my flow script or somehow 
>>>> configure the database operation?
>>>
>>>  
>>>
>>> I changed the 
>>> org.apache.cocoon.components.source.impl.XMLDBSource.XMLDBOutputStream.cl 
>>> ose () method:
>>>       public void close() throws IOException, SourceException {
>>>           if (!isClosed) {
>>>               writeOutputStream(baos.toString("UTF-8"));
>>>               baos.close();
>>>               this.isClosed = true;
>>>           }
>>>       }
>>> It used to use baos.toString() but this method uses system's default 
>>> encoding (windows-1251 in my case) to translate bytes into 
>>> characters 
>>> (http://java.sun.com/j2se/1.4.2/docs/api/java/io/ByteArrayOutputStream.ht 
>>> ml) .
>>
>>
>> It seems to me like something that should be within the XMLDBSource. 
>> But the encoding needs to be configurable somehow. If you can, feel 
>> free to supply a patch that makes it configurable.
>
>
> I agree with you. I think there should be a property in the 
> XMLDBSource class that sets the encoding and the system's default 
> encoding should still be used by default.

So are you offering to create a patch? ;-)

Upayavira



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Binding to xmldb

Posted by Timur Izhbulatov <ti...@yxo.ru>.
Upayavira писал(а): 

> Timur Izhbulatov wrote: 
> 
>> Timur Izhbulatov wrote: 
>> 
>>> Hi all! I use woody binding framework as shown in the corresponding 
>>> sample (cocoon 2.1.4) with an XML file and it works just fine. But when 
>>> I change the file URL to xmldb one my non-us (UTF-8 encoded) data are 
>>> getting corrupted. When I popultate the DB with the same data (as in 
>>> xmldb sample) it also works correctly. My sitemap entry looks as follow:
>>> ...
>>>   <map:match pattern="edit">
>>>      <map:call function="woody">
>>>        <map:parameter name="function" value="form2xml"/>
>>>      <map:parameter name="form-definition" 
>>> value="forms/form_model.xml"/>
>>>      <map:parameter name="documentURI"
>>>          value="data/1.xml"/>
>>>      <!-- <map:parameter name="documentURI"
>>>          value="xmldb:xindice-embed:///db/data/1"/> -->
>>>        <map:parameter name="bindingURI" value="forms/form_bind.xml"/>
>>>      </map:call>
>>>    </map:match>
>>> ... The form2xml function was totally borrowed from binding_example.js. 
>>> Should I rewrite my flow script or somehow configure the database 
>>> operation?
>>  
>> 
>> I changed the 
>> org.apache.cocoon.components.source.impl.XMLDBSource.XMLDBOutputStream.cl 
>> ose () method:
>>       public void close() throws IOException, SourceException {
>>           if (!isClosed) {
>>               writeOutputStream(baos.toString("UTF-8"));
>>               baos.close();
>>               this.isClosed = true;
>>           }
>>       }
>> It used to use baos.toString() but this method uses system's default 
>> encoding (windows-1251 in my case) to translate bytes into characters 
>> (http://java.sun.com/j2se/1.4.2/docs/api/java/io/ByteArrayOutputStream.ht 
>> ml) .
> 
> It seems to me like something that should 
> be within the XMLDBSource. But the encoding needs to be configurable 
> somehow. If you can, feel free to supply a patch that makes it 
> configurable.

I agree with you. I think there should be a property in the XMLDBSource 
class that sets the encoding and the system's default encoding should still 
be used by default. 


Timur 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: [SOLVED] Binding to xmldb

Posted by Upayavira <uv...@upaya.co.uk>.
Timur Izhbulatov wrote:

> Timur Izhbulatov wrote:
>
>> Hi all! 
>> I use woody binding framework as shown in the corresponding sample 
>> (cocoon 2.1.4) with an XML file and it works just fine. But when I 
>> change the file URL to xmldb one my non-us (UTF-8 encoded) data are 
>> getting corrupted. When I popultate the DB with the same data (as in 
>> xmldb sample) it also works correctly. 
>> My sitemap entry looks as follow:
>> ...
>>   <map:match pattern="edit">
>>      <map:call function="woody">
>>        <map:parameter name="function" value="form2xml"/>
>>      <map:parameter name="form-definition" 
>> value="forms/form_model.xml"/>
>>      <map:parameter name="documentURI"
>>          value="data/1.xml"/>
>>      <!-- <map:parameter name="documentURI"
>>          value="xmldb:xindice-embed:///db/data/1"/> -->
>>        <map:parameter name="bindingURI" value="forms/form_bind.xml"/>
>>      </map:call>
>>    </map:match>
>> ... 
>> The form2xml function was totally borrowed from binding_example.js. 
>> Should I rewrite my flow script or somehow configure the database 
>> operation? 
>
>
> I changed the 
> org.apache.cocoon.components.source.impl.XMLDBSource.XMLDBOutputStream.close 
> () method:
>       public void close() throws IOException, SourceException {
>           if (!isClosed) {
>               writeOutputStream(baos.toString("UTF-8"));
>               baos.close();
>               this.isClosed = true;
>           }
>       }
> It used to use baos.toString() but this method uses system's default 
> encoding (windows-1251 in my case) to translate bytes into characters 
> (http://java.sun.com/j2se/1.4.2/docs/api/java/io/ByteArrayOutputStream.html) 
> .

Please submit this to Bugzilla. It seems to me like something that 
should be within the XMLDBSource. But the encoding needs to be 
configurable somehow. If you can, feel free to supply a patch that makes 
it configurable.

Thanks, Upayavira



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org