In my opinion, one of the biggest benefits is that you can do all sorts of
things with standard XML tools. For example, the message resources could be
used as input to XSLT for various things, or as output from it.
One idea I had in mind was translation tools. Imagine if you started with a
"master" document like this:
<messages-master>
<message-master>
<key>validation.username.required</key>
<context>login page</context>
<description>Displayed when no user name is entered on login
page</description>
<text>You must enter a username</text>
</message-master>
[...]
</messages-master>
This file can be sent to a translation service where an appropriate
XML-based tool can lead the translator through the messages and let them
provide translations for the text. The final XML message resources can be
generated from the message master using XSLT.
Even better, the translated messages can be used as input to an incremental
translation process. When version 2 of the application comes out, the
translation tool can use the message master and the message resource to
identify which messages have modified text, and which new messages need to
be translated, avoiding the lengthy (and expensive) process of
re-translating the entire application.
Granted, all this could be done using property resources too. However, it
seems to me that using XML will provide a more flexible approach, given the
many XML tools available, where the message resources can be both the input
and the output.
--
Martin Cooper
At 05:32 AM 10/11/01, Young, Wayne wrote:
>What are some benefits of using XMLMessageResources over standard property
>files?
>
>Wayne Young
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[<mailto:[EMAIL PROTECTED]>mailto:[EMAIL PROTECTED]]
>Sent: Thursday, October 11, 2001 1:08 AM
>To: [EMAIL PROTECTED]
>Subject: [PROPOSAL] XMLMessageResources
>
>The Struts 1.1 TODO list contains the following item:
>
>"XmlMessageResources. Implementation of MessageResources and
>MessageResourcesFactory that loads message keys and strings from one or more
>XML resources or files."
>
>I have an implementation of this which I would like to contribute to Struts.
>The implementation is a drop-in replacement for the existing
>PropertyMessageResources. In fact, it is derived from it, and so shares the
>same file naming scheme for locale-specific messages.
>
>Here's a simple example of what an XML message file would look like:
>
>---------- begin example ----------
><?xml version="1.0" encoding="ISO-8859-1"?>
>
><messages>
> <message key="validation.username.required">You must enter a
>username</message>
> <message key="validation.password.required">You must enter a
>password</message>
> <message key="validation.password.match">Confirmation password does not
>match</message>
></messages>
>---------- end example ----------
>
>The first line of the example provides a hint as to why I did not attempt to
>incorporate messages for more than one locale into a single XML file.
>Messages for different locales may well be specified using different
>character encodings. In addition, maintaining the messages from each locale
>in a different XML file avoids loading locales unnecessarily.
>
>To use this implementation, all that is required is to specify the 'factory'
>init-param in your web.xml file, and to make sure that the 'application'
>init-param refers to an XML resource.
>
>What do people think about incorporating this into the Struts 1.1 code base?
>
>--
>Martin Cooper
>