performance - External XML for culture-specific text / Translation mapping -


we building system gets xml data database, uses xslt transform xhtml , @ same time use external xml file retrieve culture-specific labels (translations our labels).

short question
translation/culture-specific system seem logical ? efficient ?

any alternative concepts welcome (in specific context)


detailed question

xml data

<page id="55" objecttype="christianorthodoxmonument">  <field name="uniquename">some unique name here</field>         .. multiple field elements here .. </page> 

xml culture-labels

<christianorthodoxmonument>  <uniquename culture-1="Ονομασία" culture-2="unique name" />  <birthdate culture-1="Ημ/νία γέννησης" culture-2="date of birth" /> </christianorthodoxmonument> 

now in xslt pass cultureid parameter used mapping labels.

xslt (example snippet)

<xsl:param name="cultureid" select="1" /> <xsl:variable name="objecttype" select="/page/@objecttype" /> 

and map external file included

<xsl:variable name="culture" select="document('cultural-labels.xml')" /> 

i created pseudo dynamic xpath

<xsl:template name="translate">  <xsl:variable name="nodename" select="@name" />  <xsl:value-of select="$culture/*[name()=$objecttype]/*[name()=$nodename]/@*[name()=concat('culture-',$cultureid)]" /> </xsl:template> 

which call whenever want label field.

question : xpath efficient or overkill ? overcomplicated ?
question b : model seem right or missing vital prove obstacle in future ?
question c : there theory/example on similar mapping techniques external xml files ?


2nd update with composite key usage

key

<xsl:key name="find-node" match="*" use="concat(name(..),'!',name())"  /> 

lookup

<xsl:template name="lookup-label"> <xsl:param name="objecttype" /> <xsl:variable name="nodename" select="@name" /> <xsl:for-each select="$culture">     <xsl:value-of select="key('find-node',concat($objecttype,'!',$nodename))/@*[name()=$culturefield]" /> </xsl:for-each> </xsl:template> 

is improvement ?

short question translation/culture-specific system seem logical ?

yes.

efficient ?

it can efficient -- not implementation.

i created pseudo dynamic xpath

<xsl:template name="translate">   <xsl:variable name="nodename" select="@name" />   <xsl:value-of select=   "$culture/*[name()=$objecttype]                /*[name()=$nodename]                     /@*[name()=concat('culture-',$cultureid)]" 

/>

which call whenever want label field.

question a : xpath efficient or overkill ?

no, isn't efficient, because whole xml document traversed many times find specific objecttype nodes.

overcomplicated ?

no.

question b : model seem right or missing vital prove obstacle in future ?

the model ok.

question c : there theory/example on similar mapping techniques external xml files ?

there many examples of efficient lookup based on keys -- @ so. see this one.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -