cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Engelhart <mengelh...@earthtrip.com>
Subject XSL/xalan and Localization
Date Sat, 05 Feb 2000 16:40:15 GMT
Since some of the Xalan/Xerces developers are on this list plus a hand full
of other bright folks, I have a question about localization and how xalan
may or may not work with it.

After spending hours working on some XML/XSL pages late into last night, I
realized that the separation of content from style isn't really as well done
as I thought when dealing with localized applications.  Currently to get
localized strings into my web pages, I am using XSP to generate dynamic XML
which is transformed into HTML using XSLT.  I am using the JDK api
ResourceBundle class to handle this localization by calling
ResourceBundle.getBundle("com.earthtrip.MyResources",
request.getLocale).getString("_MY_i18n_STRING");
where _MY_i18n_STRING is in a properties file called MyResources with the
key/value pair
_MY_i18n_STRING=My Localized Display String

OK - now this does indeed work fine and I can create properties files for
all the languages I would want to use but here's the design problem I have.

To do this I must create relatively bogus (i.e. no meaning) XML nodes using
XSP code like:

<xsp:logic>
    Locale loc = request.getLocale();
    ResourceBundle bundle = ResourceBundle.getBundle("com.earthtrip.MyRes",
loc);
</xsp:logic>
<SUBMIT_BUTTON>
    <xsp:attribute name="xml:lang"><xsp:expr>loc</xsp:expr></xsp:attribute>
    <xsp:expr>bundle.getString("_SUBMIT_BUTTON")</xsp:expr>
</SUBMIT_BUTTON>

My question is, doesn't this kind of mix style/content and data?   I mean,
<SUBMIT_BUTTON> doesn't do anything other than allow me to use dynamic
strings inside my XSL by doing something like this:

<INPUT TYPE="SUBMIT" VALUE="{SUBMIT_BUTTON}"/>

The language "strings" being used are in my mind really part of the style of
the page.  I'm sure there are instances where the language is more integral
to the data but in this case, clearly it is not. I was thinking it would
make more sense (to me at least) to allow XSL to have either a way of
getting at localized resources during the transformation - something like
<?language-resource type="http://www.earthtrip.com/resources/lang.dtd"?>
<xsl:i18n>
    <xsl:value-of select="SUBMIT_BUTTON"/>
 <xsl:i18n>

and by wrapping the <xsl:value-of> tag inside an i18n it would look up the
approriate resource from the previous PI or something.  I apologize if the
semantics of this suck but I'm pretty new to all this.

Is this not the job of XSL?  I'm OK with what I'm doing but it just doesn't
"feel" like the separation is completely there.

Mike


Mime
View raw message