commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivelin Ivanov" <ive...@apache.org>
Subject Re: [Question] Betwix & JAXB
Date Sat, 20 Apr 2002 00:10:59 GMT

This encoding looks wise to me too.
Is this how Axis works?


James, did you have time to talk to the Axis folks, regarding a possible
reuse of the bean <-> XML code?


BTW, any idea why they named the enclosing tag <hash/> instead of <map/> ?

Thanks,

Ivelin


----- Original Message -----
From: "James Strachan" <james_strachan@yahoo.co.uk>
To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
Sent: Friday, April 19, 2002 8:57 AM
Subject: Re: [Question] Betwix & JAXB


> ----- Original Message -----
> From: "James Strachan" <james_strachan@yahoo.co.uk>
> > ----- Original Message -----
> > From: "Dmitri Plotnikov" <subscriptions@plotnix.com>
> > > 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:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:commons-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message