----- Original Message -----
From: "James Strachan" <[EMAIL PROTECTED]>
> ----- Original Message -----
> From: "Dmitri Plotnikov" <[EMAIL PROTECTED]>
> > Hi, James, Ivelin,
> >
> > [...snip...]
> >
> > > In many cases all these options would be equally good to me.
> > > Rarely do I need to customize, although when it's needed it must be
> there.
> > >
> > > >
> > > > e.g. for a Map
> > > >
> > > > Map map = new HashMap();
> > > > map.put( "a", "1234" );
> > > > map.put( "b", "5678" );
> > > >
> > > >
> > > > how should this look as XML? e.g.
> > > >
> > > ...
> > > > Or
> > >
> > > Dmitri can probably help here, but I understand that the following
form
> is
> > > becoming popular:
> > >
> > >
> > > Map map = myBean.getItem();
> > > map.put( "a", "1234" );
> > > map.put( "b", "5678" );
> > >
> > > <item id="a">1234</item>
> > > <item id="b">5678</item>
> > >
> > > which is consistent with arrays:
> > >
> > > <item id="1">1234</mapName>
> > > <item id="2">5678</mapName >
> > >
> > >
> > > And thus the XPath is natural "/mybean/item[@id='a']"
> >
> > JXPath takes a dual approach to mapping of maps, or "dynamic property
> > objects" as they are called in JXPath.
> >
> > On the one hand, you can use XPaths like "/map/foo", which are natural
> when
> > you know that the map is really just a more dynamic sister of a
JavaBean,
> so
> > "foo" is really a property of a logical "bean" called "map".  A good
> example
> > of such use is a java.util.Properties object.
>
> Though this approach only works when the keys of the Map are Strings, the
> value of which are valid XML names (no colon, > <, quotes, spaces etc).

FWIW I spotted a SOAP encoding of a Map today in this article...

http://www-106.ibm.com/developerworks/library/ws-soapmap1/

which is as follows...

     <hash xmlns:ns2="http://xml.apache.org/xml-soap"; xsi:type="ns2:Map">
     <item>
      <key xsi:type="xsd:string">2</key>
      <value xsi:type="xsd:string">two</value>
     </item>
     <item>
      <key xsi:type="xsd:string">1</key>
      <value xsi:type="xsd:string">one</value>
     </item>
     </hash>

So using elements for the key and the value can be quite useful as they can
hold type information too. A similar approach is used for Lists too.

James


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


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

Reply via email to