[xsl] Localising Submit/Clear buttons in html

Subject: [xsl] Localising Submit/Clear buttons in html
From: Ian_blizard@xxxxxx (Ian Blizard)
Date: Mon, 12 Nov 2001 14:43:38 +0000
Hello list,

Thanks to Jeni for solving my last problem, roses and chocolates are on 
the way if you can help solve this one!

I'm using a mechanism proposed by IBM DeveloperWorks for localising 
markup.  It consists of one dictionary file containing the localised 
strings, and a localisation XSL file which parses a HTML file for 
"nlsid" tags for any node, if it finds a corresponding entry in the 
dictionary file it will replace the content of the node with the content 
from the dictionary.

The params $doc-file and $currentLocale are set before the 

e.g trans.setAttribute("doc-file", "my_doc_file.xml");



<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 

	<xsl:param name="doc-file"/>
	<xsl:param name="currentLocale"/>

	<xsl:template match="text()|@*"><xsl:value-of 
	<xsl:template match="*|node()" priority="1">
			<xsl:copy-of select="@*"/><xsl:apply-templates/>
	<xsl:template match="/"><xsl:apply-templates/></xsl:template>

	<xsl:template match="*[@nlsid]" priority="5">
		<xsl:for-each select="@*">
			<xsl:if test="name()!='nlsid'">
				<xsl:copy-of select="."/>
		<xsl:apply-templates select="./*"/>
		<xsl:variable name="myKey" select="@nlsid"/>
		<xsl:when test="document($doc-file)/locale/*[name()=$myKey]">
		 <xsl:value-of select="."/>


Now that's all well and good if you want to localise the <title> node in 
HTML, e.g.

<title nlsid="PAGE_TITLE">This is my page</title>

However, when you're creating a page with forms and you need to localise 
buttons, they take their textual value from the 'Value' attribute:

<input type="submit" value="Click here to submit!"/>

Say, I add a 'nlsid' attribute to the button:

<input type="submit" value="Click here to submit!" 

With current processing is there a simple way to populate the 'value' 
attribute with the dictionary lookup?


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

Current Thread