You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by Peter Johnson <pe...@baseview.com> on 2005/09/06 20:03:19 UTC

spaces encoded as entity refs?

Hi,

I recently moved from 1.2 to 2.0 because of a problem with non ascii  
characters in strings, which 2.0 apparently solves.

However 2.0 seemed to have a bug which allows a client.execute(...)  
to return an XmlRpcException instead of throwing the exception.  So I  
went to CVS and grabbed the latest, which looks like it fixes the  
returning-an-XmlRpcException problem.

So far, so good, but then I noticed that in my strings, spaces are  
being translated to entity references.  Is this normal and expected  
behavior?  My C++ XMLRPC library that I'm using on the other end does  
not handle this.

A quick patch to XmlWriter.isValidXMLChar(char c) does the trick for me.

(This could possibly be more appropriate for the developer list, but  
I'm trying to be an XMLRPC user, not an XMLRPC developer and I'm not  
subscribed to the developer list :-) Until proven otherwise, I'll  
assume that the key developers are also on this list. )

The question is, why was it translating a space to the entity  
reference in the first place...was that intentional or a bug?  If not  
intentional, then here is how I "fixed" it.

In XmlWriter.java

was:

     private static final boolean isValidXMLChar(char c)
     {
         switch (c)
         {
         case 0x9:
         case 0xa:  // line feed, '\n'
         case 0xd:  // carriage return, '\r'
             return true;

         default:
             return ( (0x20 < c && c <= 0xd7ff) ||
                      (0xe000 < c && c <= 0xfffd) ||
                      (0x10000 < c && c <= 0x10ffff) );
         }
     }

changed to:

     private static final boolean isValidXMLChar(char c)
     {
         switch (c)
         {
         case 0x9:
         case 0xa:  // line feed, '\n'
         case 0xd:  // carriage return, '\r'
             return true;

         default:
             return ( (0x20 <= c && c <= 0xd7ff) || // <-- don't  
exclude 0x20
                      (0xe000 < c && c <= 0xfffd) ||
                      (0x10000 < c && c <= 0x10ffff) );
         }
     }