Hi Scott

> We have been using JDOM for a year or so and now you have to confuse the
world with dom4j
> which has all the bits we now know JDOM should have.....hm

Sorry about that Scott ;-)

> Anyway, one of the problems not solved by JDOM is the transparent encoding
of values represented as
> Java Strings (e.g. Attribute > value, Text Element values) into the
generated XML.

> As you know Java Strings are UNICODE. If I put a value of \uh0000 for
example as char
> in an Attribute value, JDOM generates a zero char which cannot be
re-parsed
> (XML encoding does not help as \uh0000 is an invalid XML char).
> The correct solution is to encode it in BASE64 or some such.
> It would be great to have a transparent mechanism to do this.

> A quick look at the API, I am not sure if or how this is handled in dom4j.

I've pretty much left such things out of the API per se. I didn't want to
slow things down by going through all the Strings used in Attribute values,
Text nodes, Entity values etc checking for certain UNICODE characters. I
thought that would be better to do outside of the API.

A really common use case for dom4j is creating a Document using a SAX
parser - which I would hope does this kind of encoding for you anyway? If
not, let me know and we'll see what we can do. e.g. if you've a document
that doesn't parse or round trip well, let me know and I'll get it fixed.
There may be a SAX configuration parameter, or this might be fixed in
Crimson, Xerces 2 or whatever.

Another alternative could be that we could add an encoding helper method on
DocumentHelper. So that if you know you've a String thats got wierd
characters in it then you could do something like...

    String encodedString = DocumentHelper.encode( String text );
    element.setAttrbuteValue( "foo", encodedString );
    // or
    element.setText( encodedString );

Would that help?

James



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to