Multi-language support and multiple resource files

Subject: Multi-language support and multiple resource files
From: "Rick Maddy" <rmaddy@xxxxxxx>
Date: Wed, 20 Sep 2000 10:00:56 -0600
I have a working implementation for handling multiple languages by using XML
based resource files that can be loaded by an XSLT file. However there is a
serious limitation I am trying to overcome that I hope someone can help me
out with.

First I will describe what I have that works:

I created a file named 'Resource.xsl' that knows how to read an appropriate
Resource.xml file such as Resource_en.xml or Resource_fr.xml, etc.
Resource.xsl also contains a simple named template for getting the value of
a specific resource.

All I do is create my specific xsl file and include Resource.xsl. My xsl
file then calls the named template to retrieve the resource is needs.

So far so good.

Getting trickier. I am making a large set of xsl files for a web site. These
files are arranged in a directory tree. Each directory needs to describe its
own Resource.xml files. At this level I can simply have each xsl file
include the one, common, Resource.xsl file. This currently works.
Resource.xsl is written so when it calls the 'document()' function it knows
to load the resource.xml file from the same directory as the "master" xsl
file.

Again, so far so good.

Now the real problem. Some of the xsl files in this web site are utility
files that provide common functionality. These utility xsl files are
included by other, higher level, xsl files. Both the high level xsl file,
and the utility xsl file need to include Resource.xsl so their own resource
xml data can be loaded. Boom! Doesn't work for obvious reasons. Resource.xsl
is basically getting including twice and the variable that is assigned the
value 'document()' is set twice. Obviously only one setting is valid. I get
no errors but only half my resources are actually available.

I would appreciate any ideas on how to handle this case.

Thanks,
Rick

Example: (just critical parts)

/root/util/Util.xsl -
<xsl:stylesheet ...>
<xsl:include href="Resource.xsl"/>
...

/root/util/Resource.xml -
<Resources>
<Resource xml:lang="en" key="someKey">Some text</Resource>
...

/root/util/Resource.xsl -
<xsl:variable name="res" select="document('Resource.xml', document(''))"/>
<xsl:tempate name="getResource">
<xsl:param name="key"/>
<!-- get value -->
</xsl:template>

/root/app/Master.xsl -
<xsl:stylesheet ...>
<xsl:include href="../util/Util.xsl"/>
<xsl:include href="../util/Resource.xsl"/>
...

/root/app/Resource.xml -
<Resources>
<Resource xml:lang="en" key="appKey">App text</Resource>
...


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread