Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is an XSLT 2.0 stylesheet (you can run with <a href="http://saxon.sourceforge.net/" rel="nofollow">Saxon 9</a> or <a href="http://www.altova.com/altovaxml.html" rel="nofollow">AltovaXML Tools</a> or <a href="http://www.xqsharp.com/xqsharp/beta.htm" rel="nofollow">XQSharp</a>)</p> <pre><code>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"&gt; &lt;xsl:param name="locale" select="'ES'"/&gt; &lt;xsl:key name="k1" match="Localizations/Localization[Locale = $locale]//*[Id]" use="Id"/&gt; &lt;xsl:key name="k2" match="Localizations/Localization[Locale = $locale]//*[not(Id) and not(*)]" use="local-name()"/&gt; &lt;xsl:template match="Page/Content//*[not(Id) and *]"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Page"&gt; &lt;xsl:copy&gt; &lt;xsl:copy-of select="Id"/&gt; &lt;xsl:apply-templates select="Content"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Page//*[Id]"&gt; &lt;xsl:variable name="loc" select="key('k1', Id)"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$loc"&gt; &lt;xsl:copy-of select="$loc"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:copy-of select="."/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Page//*[not(Id) and not(*)]"&gt; &lt;xsl:variable name="loc" select="key('k2', local-name())"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$loc"&gt; &lt;xsl:copy-of select="$loc"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:copy&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>But I am not sure your requirements are clearly stated and implemented by that stylesheet.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload