use variable in xslt

Variables

we can define global variable at the beginning:


<xsl:variable name="reviewTypeVar" select="/submission/submissionModel/dataValue[@fieldName = 'reviewPrograms']/@value"/>
 <xsl:variable name="reviewTimeVar" select="/submission/submissionMetadata/@submitedOn"/>

TO use the variable just use: $


	<!-- Root level template -->
	<xsl:template match="submissionModel">
		<appendAndReplaceCommand>
			<xsl:if test="not(./dataValueGrid[@name=reviewHistoryList])">
				<dataValueGridAppendAndReplace name="reviewHistoryList">
					<row number="0">
						<dataValueAppendAndReplace fieldName="reviewRequestedDate">
							<xsl:value-of select="$reviewTimeVar" />
						</dataValueAppendAndReplace>
						<dataValueAppendAndReplace fieldName="reviewType">
							<xsl:value-of select="$reviewTypeVar" />
						</dataValueAppendAndReplace>
					</row>
				</dataValueGridAppendAndReplace>
			</xsl:if>
			<xsl:apply-templates />
		</appendAndReplaceCommand>
	</xsl:template>

not AND concat

use not() in the xls:if for negative:
<xsl:if test=”not(./dataValueGrid[@name=reviewHistoryList])”>….</xls:if>

use concat() for string concat, use “,” to seperate:
<xsl:value-of select=”concat(‘/Application/DirectFormAccess.jsp?requestInstance=’, $reviewInstanceIdVar)” />

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s