I am new to XSL:key.
Could any one tell for the following,
1) <xsl:variable name="result" select="key($index,$key)"/> what it does
2) To find long descripting, the existing xsl mapping for Type="PP" and
searching keyword for ZZ. Question: without specifying the attibue name
such as Pkey and Type....How it searching the output of LongDes as ZO
Contracts ???
From the exising Input xml file,
<Document>
<Legend>
<TypeDesc Type="PP" Id="1" PKey="ZZ" xml:lang="EN" ShDes="ZZ"
LongDes="ZO Contracts"/>
</Legend>
</Document>
Requirement: To find LongDes
Exising XSL file:
<xsl:call-template name="getLegend">
<xsl:with-param name="cat" select="'PP'"/>
<xsl:with-param name="key" select="'ZZ'"/>
</xsl:call-template>
<xsl:template name="getLegend">
<xsl:param name="cat"/>
<xsl:param name="key"/>
<xsl:call-template name="lookup">
<xsl:with-param name="index" select="'legendIndex'"/>
<xsl:with-param name="key"
select="concat($cat,'_',$key)"/>
<xsl:with-param name="doc" select="$legend"/>
<xsl:with-param name="expr" select="'@LongDes'"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="lookup">
<!-- index name, i.e. name of the key -->
<xsl:param name="index"/>
<xsl:param name="key"/>
<!-- default value -->
<xsl:param name="default" select="''"/>
<!-- node in index source document, per default default value
-->
<xsl:param name="doc" select="$default"/>
<!--expr to evaluate to return value, per default result node
-->
<xsl:param name="expr" select="'.'"/>
<!-- force context to document where the lookup table is -->
<xsl:for-each select="$doc[1]">
<xsl:variable name="result" select="key($index,$key)"/>
<xsl:choose>
<xsl:when test="$result">
<xsl:value-of
select="xalan:evaluate(concat('$result[1]/',$expr))"/>
</xsl:when>
<xsl:when test="$default">
<xsl:value-of select="$default"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--