Upayavira wrote:

Upayavira 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?



How good is your Java? Can you take a look at the source for the XMLDBTransformer, and compare it to the code for the XMLDBSource (both in the XMLDB block). To bind to an XMLDB source, like you are, you're using the XMLDB source as a modifiable source, so the getOutputStream() method should be crucial. Maybe the XMLDBTransformer (which is used in the XMLDB sample) takes more care over encoding.


I've just had a look into this. The XMLDBTransformer uses the incoming XML stream to build the doc, and sets the encoding to UTF-8. It doesn't seem like this is configurable at all.

The XMLDBSource just takes an input stream, so it depends entirely upon what encoding the Woody/CForms binding framework is using. If Woody is creating the 'bound' xml, then how does it define the encoding it uses when it writes that XML to an output stream?


I don't get the question (oh this fuzzy head in the morning)


woody/cforms binding isn't doing a thing with encoding, since it's operating in pure Java space only, it is not writing XML it is purely handling the DOMNodes.

and since you say the source implementation isn't doing it, I can only conclude we have to check the flowscript:

in the form2xml sample the one doing the conversion from dom-nodes back to xml is the saveDocument() function

I suggest adding

transformer.setOutputProperty(Packages.javax.xml.transform.OutputKeys.ENCODING, "utf-8");

which will enforce utf-8 encoding to all saved content.
alternatively you could find some way to check the encoding during 'load' and then reuse the same for the 'save'


HTH,
-marc=
--
Marc Portier                            http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at                http://blogs.cocoondev.org/mpo/
[EMAIL PROTECTED]                              [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to