Reputation: 13915
The idea is to select subset of labels with specific language code:
<xsl:variable name="extLangCode" select="//Invoice/@languageId" />
<xsl:include href="./labels.xsl" />
<xsl:variable name="labelsXml">
<xsl:call-template name="labels" />
</xsl:variable>
<xsl:variable name="labels" select="$labelsXml/labels/label[@lang=$extLangCode]" />
a part of labels.xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="labels">
<labels>
<label key="pageNr" lang="kl">Page</label>
<label key="pageNr" lang="en">Page</label>
It throws:
[FATAL]: Error checking type of the expression 'FilterParentPath(variable-ref(labelsXml/result-tree), ParentLocationPath(step("child", 16), step("child", 18, pred(=(step("attribute", 17), variable-ref(extLangCode/node-set))))))'.
Upvotes: 1
Views: 2554
Reputation: 167516
Xalan is an XSLT 1 processor, in XSLT 1 your variable is a result tree fragment and you can't apply XPath on result tree fragments without converting them first to node-sets so you need e.g. <xsl:variable name="labels" select="exsl:node-set($labelsXml)/labels/label[@lang=$extLangCode]" xmlns:exsl="http://exslt.org/common"/>
.
Upvotes: 2