I’m wondering what the easiest (and most resource friendly) way would be to transform following XML example
<index>
<element_1>
<local xml:lang="en">Something in English</local>
<local xml:lang="bg">Something in Bulgarian</local>
<local xml:lang="cs">Something in Czech</local>
<!-- more locales from here -->
</element_1>
<element_2>
<local xml:lang="en">Something else in English</local>
<local xml:lang="bg">Something else in Bulgarian</local>
<local xml:lang="cs">Something else in Czech</local>
<!-- more locales from here -->
</element_2>
<!-- more elements from here -->
</index>
Into following XML so I could store it in a parameter
<index>
<element_1>Something in English</element_1>
<element_2>Something else in English</element_2>
<!-- more elements from here -->
</index>
I know the below xslt does the trick, but since my actual files are much bigger and more complex as above example I was wondering if there are easier ways to achieve this. So using XPath instead of a template for instance. Any recommendation ?
<xsl:param name="indexNode" select="/index"/>
<xsl:param name="language">en</xsl:param>
<xsl:template match="/">
<xsl:for-each select="$indexNode">
<xsl:copy>
<!-- index node -->
<xsl:for-each select="node()">
<!-- element node -->
<xsl:copy>
<!-- locale node -->
<xsl:value-of select="local[lang($language)]"/>
</xsl:copy>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:template>
Thanks in advance !
A simple way of doing this – assuming you just want to filter out the english ones