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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I change existing xslt code to a simple statement?

Status
Not open for further replies.

momo2000

Programmer
Jan 2, 2015
63
US
I have the following existing xslt code. I would like to replace this code with a simple statement where I check the first three characters of CaseType/@Word = CNV instead.

Code:
			<xsl:variable name="ConvertedFELOrGMD">
				<xsl:choose>
					<xsl:when test="CaseType/@Word = 'CNVAWI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVBWI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDAF'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDAG'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDAM'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDAT'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDWI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDWK'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVFDA'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVFDK'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVFDW'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVFEL'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVFFD'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVFWI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVGDI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVGFD'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVGMD'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVHWI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVKOT'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVSFL'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVSWI'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDFL'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVDGM'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVJFL'">true</xsl:when>
					<xsl:when test="CaseType/@Word = 'CNVJGM'">true</xsl:when>
					<xsl:otherwise>false</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
 
If you need ConvertedFELOrGMD to hold the string value of "true" or "false":
Code:
<xsl:variable name="ConvertedFELOrGMD">
  <xsl:choose>
    <xsl:when test="substring(CaseType/@Word, 1, 3) = 'CNV'">true</xsl:when>
    <xsl:otherwise>false</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

If you need ConvertedFELOrGMD to hold a boolean value:
Code:
<xsl:variable name="ConvertedFELOrGMD" select="substring(CaseType/@Word, 1, 3) = 'CNV'"/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top