You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Yixing Ma <Yi...@interfacemgmt.net> on 2005/11/01 19:36:28 UTC

array datatype question

Hi developers,

As I'm starting to use apache's XML-RPC java api, I found couple of questions.

1)  The standard XML-RPC spec defines the array type as something like:
**********************************************************************
<array>
  <data>
    <value><i4>1404</i4></value>
    <value><string>Something Here</string></value>
  </data>
</array>
***********************************************************************
But I was unable to put <i4> into the array by using java Vector. I could only put <int></int> instead of <i4>. Also the <string></string> tag in red is missing.  The blank space was replaced by "&#32;" in the generated XML.

My code is: 
**********************************
Vector v=new Vector();        * 
v.add(new Integer("1404")); *
v.add("Something Here");    *
**********************************                 
 The result XML is 
**********************************************************************
<array>
  <data>
    <value><int>1404</int></value>
    <value>Something&#32;Here</value>
  </data>
</array>
**********************************************************************

Is there a way to produce the exact same XML as XML-RPC defined by using apache's api?

2) If I want to generate 
<array>
  <data>
    <value><i4>001404</i4></value>
  </data>
</array>

as I want to preserve the zero before 1404. What should I do?

Best regards,
Yixing Ma

Re: array datatype question

Posted by Jochen Wiedmann <jo...@gmail.com>.
Yixing Ma wrote:

> 1)  The standard XML-RPC spec defines the array type as something like:
> **********************************************************************
> <array>
>   <data>
>     <value><i4>1404</i4></value>
>     <value><string>Something Here</string></value>
>   </data>
> </array>
> ***********************************************************************
> But I was unable to put <i4> into the array by using java Vector. I could only put <int></int> instead of <i4>. Also the <string></string> tag in red is missing.  The blank space was replaced by "&#32;" in the generated XML.

...

> Is there a way to produce the exact same XML as XML-RPC defined by using apache's api?

Your questions boil down to the customization of the generated XML. That
discussion came up recently: See
 http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-dev/200510.mbox/%3c4342E7D3.3010203@gmail.com%3e

for more details.

As I already have explained in that thread, I'd vote against any attempt
to make xml-rpc more customizable in that area by adding more and more
flags like "useInt" (and not i4) or "alwaysUseString" (as opposed to
omitting the unnecessary type declaration for strings), and so on. On
the other hand, I am open for a solution, that allows the xml-rpc user
to take over control of the serialization. If you'd like to work in that
area, feel free to supply patches.

However, keep in mind, that you are doing yourself no favour, when
relying on such syntactical details. Best option is not to depend on a
certain syntax.


Jochen