IBM®
跳转到主要内容
    中国 [选择]    使用条款
 
 
Select a scope: Search for:    
    首页    产品    服务与解决方案     支持与下载    个性化服务    
跳转到主要内容

developerWorks 中国  >  Web development | XML  >

An XSLT style sheet and an XML dictionary approach to internationalization

Minimize the number of files you need to edit when the content on your site changes

developerWorks

Return to article.


Generic XSLT stylesheet
        
	<?xml version='1.0'?>
	<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:param name="doc-file"/>
	<xsl:param name="currentLocale"/>
	<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
	<xsl:template match="*|node()" priority="1">
		<xsl:copy>
			<xsl:copy-of select="@*"/><xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="/"><xsl:apply-templates/></xsl:template>
	<xsl:template match="*[@nlsid]" priority="5">
	   <xsl:copy>
		<xsl:copy-of select="@*"/>
		<xsl:apply-templates select="./*"/>
		<xsl:variable name="myKey" select="@nlsid"/>
		<xsl:choose>
		<xsl:when test="document($doc-file)/locale/*[name()=$myKey]">
                <xsl:value-of select="document($doc-file)/locale/*[name()=$myKey]/*[name()=$currentLocale]"/>
		</xsl:when>
		<xsl:otherwise>
		 <xsl:value-of select="."/>
		</xsl:otherwise>
		</xsl:choose>
	    </xsl:copy>	
	</xsl:template>
	</xsl:stylesheet>
	
      

Return to article.

    关于 IBM 隐私条约 联系 IBM 使用条款