forum  

Re: [Forum] XML attribute value indirection

List for Users of Carlsbad Cubes' Technologies and Products
Mon, 10 Oct 2005 15:21:16 -0700

Hi all,

This does sound as a not bad idea to me.
The main reason is that it makes localization (or more generally
indirection) explicit.
Indeed, looking at the following snippet you can't really say whether
"ok" is a text or a key in the localization file.
...
<button text="ok" />
..
while this is selfexplained
<button text="@ok" />

Second, this approach makes it very easy to write some automated tool
to check whether every key in swixml descriptor has corresponding
entry in localization file.
This could be an issue while refactoring large applications.

Thanks,
Vitali


2005/9/26, List for Users of Carlsbad Cubes' Technologies and Products
<Forum@carlsbadcubes.com>:
> Hi there,
>
> I'm a new SwixML user and would like to submit
> a proposal.
>
> The Need:
> ========
>
> Looking at how the StringConverter classes localizes
> attribute values using essentially a properties file, it
> seems to me it would be useful if we could extend this
> model so that *all* attribute values could be indirected,
> when necessary.
>
> In the following snippet ...
>
> <frame name="mainframe"
>       size="640,480"
>       title="S W I X M L"
>       defaultCloseOperation="JFrame.EXIT_ON_CLOSE"
>       defaultLookAndFeelDecorated="true"
>       bundle="ui.locale.swix">
>
>  <menubar name="menubar">
>    <menu name="filemenu" text="mus_File" font="SansSerif--12">
>      <menuitem name="mi_new"
>                text="mus_New"                      font="SansSerif--12"
>                icon="ui/icons/new.gif"
>                mnemonic="VK_N"
>                accelerator="control N"
>                action="newAction"    />
>
> ...the font attribute assignment (font="SansSerif--12")
> will likely be sprinkled liberally elsewhere across the
> file.  If I change that font value in one place, I will
> likely need to change the other font values elsewhere
> in the file, also.  So you can see a basic need for
> indirection: I need a central place to be able to assign
> font values to a whole bunch of components.
>
> Besides fonts, other component attributes might need
> to be centralized in one place (e.g. the background
> color).
>
> The Problem:
> ==========
>
> I *could* try...
>
> <frame name="mainframe"
>       size="640,480"
>       title="S W I X M L"
>       defaultCloseOperation="JFrame.EXIT_ON_CLOSE"
>       defaultLookAndFeelDecorated="true"
>       bundle="ui.locale.swix">
>
>  <menubar name="menubar">
>    <menu name="filemenu" text="mus_File" font="menu.font">
>      <menuitem name="mi_new"
>                text="mus_New"                      font="menu.font"
>                icon="ui/icons/new.gif"
>                mnemonic="VK_N"
>                accelerator="control N"
>                action="newAction"    />
>
> ...with...
>
> menu.font = SansSerif--12
>
> ...defined in the swix.properties file.
>
> This wont work of course, because only StringConverter
> applies the PropertyResourceBundle to the parsed attribute
> values.
>
>
> Proposal:
> =======
>
> If an attribute value starts with an escape character, say '@'
> (perhaps with '@@' escaping itself), then the *parser*--not the
> converter, attempts to "localize" the XML attribute value before
> passing it off to the converter.
>
> Alternatively, we could forget about the special escape character
> and attempt to "localize" all attribute values, willy nilly.  Personally,
> I'm not for this: it would be better to make the indirection more
> explicit: right now, in order to see if a string is localized, you have
> to check the properties file; you can't tell just from looking at the
> XML.
>
> What do you think?
>
> -Babak
>
> _______________________________________________
> Forum mailing list
> Forum@carlsbadcubes.com
> http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
>

_______________________________________________
Forum mailing list
Forum@carlsbadcubes.com
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com