Canonicalizing XML and UTF-8 problem

5 views
Skip to first unread message

bgoetzmann

unread,
Jul 11, 2008, 5:39:38 PM7/11/08
to Mesh4x Discussion
Hello,

In Mesh4j, I got an exception when trying to read a well formed XML
feed (using UTF-8 encoding) that contains french accented caracters in
a item's payload:

Caused by: com.mesh4j.sync.validations.MeshException:
org.xml.sax.SAXParseExcept
ion: Invalid byte 2 of 3-byte UTF-8 sequence.
at
com.mesh4j.sync.utils.XMLHelper.canonicalizeXML(XMLHelper.java:130)
at com.mesh4j.sync.model.Content.refreshVersion(Content.java:
49)
at com.mesh4j.sync.model.Content.<init>(Content.java:22)
at
com.mesh4j.sync.adapters.feed.XMLContent.<init>(XMLContent.java:17)
at
com.mesh4j.sync.adapters.feed.FeedReader.readItem(FeedReader.java:150
)
at
com.mesh4j.sync.adapters.feed.FeedReader.read(FeedReader.java:115)
at
com.mesh4j.sync.adapters.feed.FeedReader.read(FeedReader.java:71)
at
com.mesh4j.sync.adapters.feed.FeedReader.read(FeedReader.java:103)
at
com.mesh4j.sync.adapters.feed.FeedAdapter.<init>(FeedAdapter.java:74)

at FeedSyncController
$_closure7.doCall(FeedSyncController.groovy:83)
at FeedSyncController
$_closure7.doCall(FeedSyncController.groovy)

In effect this exception was raised by one of the
XMLHelper.canonicalizeXML methods when reading the item that contained
accented caracters. When it's not the case, all works well.

So to resolve this problem, I changed:
byte[] result = c.engineCanonicalize(xml.getBytes());
by:
byte[] result = c.engineCanonicalize(xml.getBytes("UTF-8"));

Hope this help !


Bertrand.

http://www.odelia-technologies.com/

Marcelo Tondato

unread,
Jul 14, 2008, 9:18:03 AM7/14/08
to mes...@googlegroups.com
Done.

Marcelo Tondato

unread,
Jul 14, 2008, 9:54:20 AM7/14/08
to mes...@googlegroups.com
Bertrand,
  you have been a great help with mesh4j.
  Any suggestions would be more than welcome.

JMT

bgoetzmann

unread,
Jul 18, 2008, 3:40:00 AM7/18/08
to Mesh4x Discussion
Thank you,

I almost finished my web application that uses Mesh4j ; this
application is developed with the powerful Grails framework, and with
the help of Ext Js (a RIA in JavaScript) for the "view" part ; when
you have two running instances of this application, you can
synchronize feeds between them. These files are backed in files (I use
the classes FileSyncApdater et HttpSyncAdapter).
I will go a step further by writing a special adapter using Grails
domain classes to haves feeds saved in a relational database ; I know
these is an Hibernate adapter, but Grails has a very good support of
persistence and uses internally JEE frameworks like Spring or
Hibernate.
For the web pages, I will go toward a combination of GSP (Groovy
Server Pages) and GWT-Ext (Google Web Toolkit with the Ext Js
framework), in order to have a better integration of Ext Js.

I think I will return to this forum !

Thank you again for your help.


Bertrand
http://www.odelia-technologies.com/


On 14 juil, 15:54, "Marcelo Tondato" <jtond...@gmail.com> wrote:
> Bertrand,
>   you have been a great help with mesh4j.
>   Any suggestions would be more than welcome.
>
> JMT
>
> On Mon, Jul 14, 2008 at 10:18 AM, Marcelo Tondato <jtond...@gmail.com>
> wrote:
>
>
>
> > Done.
>
> > On Fri, Jul 11, 2008 at 6:39 PM, bgoetzmann <bgoetzm...@sophia.symag.com>
> >>http://www.odelia-technologies.com/- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

Daniel Cazzulino

unread,
Jul 18, 2008, 4:01:19 AM7/18/08
to mes...@googlegroups.com
awesome!

is there any online site we can link to that showscases this?

thanks!

Goetzmann Bertrand

unread,
Jul 18, 2008, 4:10:07 AM7/18/08
to mes...@googlegroups.com
I will soon put this test application on my web site GrailsWorks, in the web application GrailsBox (http://www.grailsworks.com)!

Cheers,

Bertrand.

-----Message d'origine-----
De : mes...@googlegroups.com [mailto:mes...@googlegroups.com] De la part de Daniel Cazzulino
Envoyé : vendredi 18 juillet 2008 10:01
À : mes...@googlegroups.com
Objet : [mesh4x] Re: Canonicalizing XML and UTF-8 problem
Reply all
Reply to author
Forward
0 new messages