Note that there are some explanatory texts on larger screens.

plurals
  1. POMatching different node handles to get a node value with XSLT
    text
    copied!<p>XSLT available is 1.0.</p> <p>I'm working on a dual-language site in an XML-based CMS (Symphony CMS), and need to replace the English version of a category name with the French version.</p> <p>This is my source XML.</p> <pre><code>&lt;data&gt; &lt;our-news-categories-for-list-fr&gt; &lt;entry id="118"&gt; &lt;title-fr handle="technology"&gt;Technologie&lt;/title-fr&gt; &lt;/entry&gt; &lt;entry id="117"&gt; &lt;title-fr handle="healthcare"&gt;Santé&lt;/title-fr&gt; &lt;/entry&gt; &lt;/our-news-categories-for-list-fr&gt; &lt;our-news-article-fr&gt; &lt;entry id="100"&gt; &lt;categories&gt; &lt;item id="117" handle="healthcare" section-handle="our-news-categories" section-name="Our News categories"&gt;Healthcare&lt;/item&gt; &lt;item id="118" handle="technology" section-handle="our-news-categories" section-name="Our News categories"&gt;Technology&lt;/item&gt; &lt;/categories&gt; &lt;main-text-fr mode="formatted"&gt;&lt;p&gt;Blah blah&lt;/p&gt;&lt;/main-text-fr&gt; &lt;/entry&gt; &lt;/our-news-article-fr&gt; &lt;/data&gt; </code></pre> <p>This is part of the XSLT that I currently have for the French version.</p> <pre><code>&lt;xsl:template match="data"&gt; &lt;xsl:apply-templates select="our-news-article-fr/entry"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="our-news-article-fr/entry"&gt; &lt;xsl:if test="categories/item"&gt; &lt;p class="category"&gt;In:&lt;/p&gt; &lt;ul class="category"&gt; &lt;xsl:for-each select="categories/item"&gt; &lt;li&gt;&lt;a href="{/data/params/root}/{/data/params/root-page}/our-news/categorie/{@handle}/"&gt;&lt;xsl:value-of select="."/&gt;&lt;/a&gt;&lt;/li&gt; &lt;/xsl:for-each&gt; &lt;/ul&gt; &lt;/xsl:if&gt; &lt;/xsl:template match&gt; </code></pre> <p>The problem: the visible text of the anchor (<code>&lt;xsl:value-of select="."/&gt;</code>) gives the English version of the category title.</p> <p>The handles of the following nodes match (all handles are in English), and so I'm thinking I should be able to match one from the other.</p> <p><code>/data/our-news-categories-for-list-fr/entry/title-fr/@handle</code> (value of title-fr node is French translation of category title)</p> <p><code>/data/our-news-article-fr/entry/categories/item/@handle</code></p> <p>I'm new to XSLT and am struggling to find how to do this.</p> <p>Many thanks.</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