Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter Template Match By Global Param

Status
Not open for further replies.

JSpicolli

Programmer
Apr 2, 2004
208
US
Can I filter a Template Match by a global Param?

This First Code block Works:, but the seconds does not and the Only Difference between the two is the first has the filter hard-coded the second tries to use the param value.


Code:
<xsl:stylesheet version="2.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
   	
[highlight]
	<xsl:param name="Param_ParticipantIsManaged" select="'1'"/>
[/highlight]

	<xsl:variable name="v_ParticipantIsManaged">
		<xsl:value-of select="$Param_ParticipantIsManaged"/>
	</xsl:variable>
	
	<xsl:output method="xml"/>
	<!-- ROOT -->
	<xsl:template match="/">
		<TEST v="{$Param_ParticipantIsManaged}"/>

		<xsl:apply-templates select="/ExchangeRtParticipants/AgreementParticipant"/>
	</xsl:template>
[highlight]
	<xsl:template match="AgreementParticipant[@ParticipantIsManaged='1']">[/highlight]
		<ExchangeRtParticipants  test="{$v_ParticipantIsManaged}">
			<AgreementParticipant Identifier="{@Identifier}" ReinscReferenceNicknameTxt="{@ReinscReferenceNicknameTxt}" 
				SourceCurrencyTypeCode="{@SourceCurrencyTypeCode}" ReinscReferenceNameTxt="{@ReinscReferenceNameTxt}" 
				ReinscTypeDsc="{@ReinscTypeDsc}" SourceCurrencyTypeId="{@SourceCurrencyTypeId}" 
				TargetCurrencyTypeCode="{@TargetCurrencyTypeCode}" TargetCurrencyTypeId="{@TargetCurrencyTypeId}"
				BeginDt ="{@BeginDt}" Rate="{@Rate}" RateSource="{@RateSource}" 
				ParticipantIsManaged="{@ParticipantIsManaged}"
			/>
		</ExchangeRtParticipants>
		
	</xsl:template>

</xsl:stylesheet>

But this code does not work:

Code:
<xsl:stylesheet version="2.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
   	

	<xsl:param name="Param_ParticipantIsManaged" select="'1'"/>

	<xsl:variable name="v_ParticipantIsManaged">
		<xsl:value-of select="$Param_ParticipantIsManaged"/>
	</xsl:variable>
	
	<xsl:output method="xml"/>
	<!-- ROOT -->
	<xsl:template match="/">
		<TEST v="{$Param_ParticipantIsManaged}"/>

		<xsl:apply-templates select="/ExchangeRtParticipants/AgreementParticipant"/>
	</xsl:template>
[highlight]
	<xsl:template match="AgreementParticipant[@ParticipantIsManaged='{$Param_ParticipantIsManaged}']">[/highlight]
		<ExchangeRtParticipants  test="{$v_ParticipantIsManaged}">
			<AgreementParticipant Identifier="{@Identifier}" ReinscReferenceNicknameTxt="{@ReinscReferenceNicknameTxt}" 
				SourceCurrencyTypeCode="{@SourceCurrencyTypeCode}" ReinscReferenceNameTxt="{@ReinscReferenceNameTxt}" 
				ReinscTypeDsc="{@ReinscTypeDsc}" SourceCurrencyTypeId="{@SourceCurrencyTypeId}" 
				TargetCurrencyTypeCode="{@TargetCurrencyTypeCode}" TargetCurrencyTypeId="{@TargetCurrencyTypeId}"
				BeginDt ="{@BeginDt}" Rate="{@Rate}" RateSource="{@RateSource}" 
				ParticipantIsManaged="{@ParticipantIsManaged}"
			/>
		</ExchangeRtParticipants>
		
	</xsl:template>
 
Don't use curly brackets:
Code:
<xsl:template match="AgreementParticipant[@ParticipantIsManaged = $Param_ParticipantIsManaged]">
Also, you don't need the single quotes around the value of the param, although I don't think it makes a difference:
Code:
<xsl:param name="Param_ParticipantIsManaged" select="1"/>

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top