[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[no subject]

[no subject]
<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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.