xsl-list
[Top] [All Lists]

RE: XML style selected by browser language setting?

2004-06-30 03:31:06
You can't do what you want with only an xml/xslt file. You could have an html page that reads the client's language setting, chooses an xslt file accordingly and transforms an xml file via script.


--

Joe


From: "Andrew Welch" <ajwelch(_at_)piper-group(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: RE: [xsl] XML style selected by browser language setting?
Date: Wed, 30 Jun 2004 11:15:34 +0100


I think your only option here is to use clientside script to perform the
transform, and then pass in the language setting as a parameter.  As
it's clientside in IE you will be using msxml3 (unless you use script,
in which case you could use msxml4 if it's available), and I don't think
that has an extention function to obtain the langauge setting.

Visit

http://www.w3schools.com/xsl/xsl_client.asp

For some tutorial on clientside transforms.

cheers
andrew

> This is what I am trying to achieve without much success so far:
>
> On a local harddrive or network (so there is no web server
> involved) the user will point his file browser at some xml
> file. The xml file will reference an xsl stylesheet like this:
>
> <?xml-stylesheet type="text/xsl" href="Stylesheet.xsl"?>
>
> My aim is for the stylesheet to find out the language setting
> of the user's browser. I have tried JavaScript
> navigator.language. While I managed to show the language
> setting in the browser window, what I really want, is to
> select language dependent style info, like keywords, data
> format, etc., based on the language setting. So, if my xml
> file contains something like this:
>
> <Distance>100</Distance>
>
> With a browser language setting of German this might
> automatically be displayed as:
>
> Entfernung: 100 km
>
> and with English-US as:
>
> Distance: 62 miles
>
> My problem is not having multiple stylesheets achieving this,
> or using external files with the language dependent info, the
> problem is the automatic selection of the proper styling
> based on the browser setting.
>
> I do not want to have the user having to select a language by
> some on-screen mechanism. This only has to work in Internet
> Explorer 6.0, but if this also works for other browsers that
> would be even better.
>
> Since I am relatively new to the combination of xsl and
> scripting I would appreciate an answer with foolproof
> examples that I can understand.

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>