-
Notifications
You must be signed in to change notification settings - Fork 40
Multilingual sites: display of multilingual metadata
The practice used in the IOSPE project for encoding metadata in multiple languages is to create duplicate elements distinguished by the value of the xml:lang attribute. Here is an example:
<msContents>
<summary corresp="document-search.xml#doc1">
<seg xml:lang="ru">Строительная надпись.</seg>
<seg xml:lang="en">Building inscription.</seg>
</summary>
</msContents>
It is generally a good practice to do so as it cuts the number of files we have to work with and allows for a better control over the translation. However, when we put the files into content/xml/epidoc and transform them using the EpiDoc XSLT the display in EFES has both languages one after the other.
In order to solve this problem we need to preprocess the EpiDoc xml files before they get transformed by the EpiDoc stylesheets. It would be useful to only transform the elements having the xml:lang attribute with the value of the language that was passed as a parameter in the url. Preprocessing is done in webapps/ROOT/sitemaps/internal.xmap. We need to change the <map:match>
that processes the EpiDoc document in a language context prior to its use in another pipeline - this map:match starts at circa line 48. As it is, this map:match only generates content from the file disc and serializes it as xml. We need to add a <map:transform>
that will use a stylesheet which will remove the elements with the xml:lang attribute not matching the language parameter supplied in the url. Such a stylesheet does not exist yet so we need to create one in webapps/ROOT/stylesheets/epidoc. Let's name it prune-to-language.xsl.
We begin by defining a parameter to the transformation:
<xsl:param name="language"/>
We then need to write a template that matches on any element that has the xml:lang attribute different from the supplied language parameter. This template is empty so it effectively leaves them out:
<xsl:template match="*[@xml:lang!=$language]"/>
This would also leave out the <div edition="type">
, so we need to write another template that will make a copy of it. Let us also give it a priority="10":
<xsl:template priority="10" match="tei:div[@type='edition']">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
The next template will make a copy of all attributes and nodes (those that are left and therefore have the value of xml:lang equal to the parameter language):
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
Lastly we can write another template about any content in <foreign>
elements so we get them displayed:
<xsl:template match="tei:foreign" priority="10">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
We can now include the map:transform using this xsl in the map:match in internal.xmap. Inside the <map:transform>
element we need to pass the language parameter with value="{1}" as this is the first variable supplied in through the url. This is how the entire map:match should look like when we're done:
<map:match id="local-preprocess-epidoc-language"
pattern="epidoc/preprocess/language/*/**.xml">
<map:generate src="../content/xml/epidoc/{2}.xml" />
<map:transform src="../stylesheets/epidoc/prune-to-language.xsl">
<map:parameter name="language" value="{1}" />
</map:transform>
<map:serialize type="xml" />
</map:match>