|
From: Darren D. <da...@da...> - 2004-04-27 09:49:06
|
=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tuesday 27 April 2004 10:21, j=FCrgen h=F6ller [werk3AT] wrote:
> A colleague of mine just suggested that <entry> tags in XML bean
> definitions should also support non-String keys: After all, a
> java.util.Map can take any Object as key.
>
> So instead of just the current:
>
> <map>
> <entry key=3D"myKey">
> <ref bean=3D"myTarget"/>
> </entry>
> </map>
>
> We could also support something like the following:
>
> <map>
> <entry>
> <key>
> <ref bean=3D"myKey"/>
> </key>
> <ref bean=3D"myTarget"/>
> </entry>
> </map>
>
> The problem is the syntax: It looks odd to have the <ref> Map value at
> the same level as the <key> subtag, with the latter having a nested <ref>
> again...
>
> Any ideas?
<map>
<!-- as now: String key -->
<entry key=3D"myKey">
<ref bean=3D"myTarget"/>
</entry>
</map>
1. consistent DTD
<map>
<!-- kludgy..? symbolised bean reference -->
<entry key=3D"@myBean">
<ref bean=3D"myTarget"/>
</entry>
</map>
2. add ref to DTD attr list for map/entry
<map>
<entry ref=3D"myBean">
<ref bean=3D"myTarget"/>
</entry>
</map>
Both suffer from losing the ability to declare 'local' or 'bean' but that=20
might not matter since neither may be capable of being validated via DTD=20
anyway - I'm no DTD expert.
Both are backward compatible though - if we go with <key> as an element=20
rather than an attribute, existing context definitions will break won't=20
they (unless the String version remains as an attribute which would be=20
somewhat confusing I think)
I wonder though what the use case would be. I think using objects other=20
than strings as map keys is a common requirement in application code, but=20
in setting up a context? I'm not sure - did your colleague have a=20
particular scenario in mind that could better be handled with such a=20
change, or was it a discussion item? It'd be interesting to know!
=2D --=20
Darren Davison
Public Key: http://www.davison.uk.net/key.jsp
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAjiyJKLMLAN01aw0RAp1ZAJ47umxiqboVg9lju9Dnn/Tznv8F4QCeKBCP
oHLwMJQ52Xe8pDxeWFeg+cI=3D
=3Ds02n
=2D----END PGP SIGNATURE-----
|