Jump to content

If Conditions


Krishn60

Recommended Posts

I need some help. I have an XML file <Cartoons> <Cartoon Type=”L” Size=”Big” Volume=”43”/> <Cartoon Type=”U” Size=”Large” Volume=”12298”/> <Cartoon Type=”S” Size=”Medium” Volume=”4”/></Cartoons>I need to create a text file from the above based on the “Type” value . The out put file should beIf Type is L then REE|Big|||||||||| (or)If Type is U ThenREE||Large||||||||| (or)If Type is S ThenREE|||Medium||||||||I cannot have 3 if statements, due to other functionality in my code. I tried the below but it is not working. Please help.REE |<xsl:value-of select="if (@Type='L' then @Size"/>|<xsl:value-of select="if (@Type='U' then @Size"/>|<xsl:value-of select="if (@Type='S' then @Size"/>||||||||Thanks

Link to comment
Share on other sites

Uhh... I hate spelling out stuff that has already been said in pseudo code (your initial explanation), but OK...

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="text" /><xsl:template match="/"><xsl:apply-templates/></xsl:template><xsl:template match="Cartoon">REE|<xsl:choose><xsl:when test="@Type = 'L'">Big||</xsl:when><xsl:when test="@Type = 'U'">|Large|</xsl:when><xsl:when test="@Type = 'S'">||Medium</xsl:when></xsl:choose>||||||||</xsl:template></xsl:stylesheet>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...