Krishn60 Posted January 15, 2009 Share Posted January 15, 2009 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 More sharing options...
boen_robot Posted January 15, 2009 Share Posted January 15, 2009 Use xsl:choose instead. Link to comment Share on other sites More sharing options...
Krishn60 Posted January 15, 2009 Author Share Posted January 15, 2009 Can you please tell me how to do that in the above example. I am unable to embed xsl:choose code in my logic. Thanks for your help. Link to comment Share on other sites More sharing options...
boen_robot Posted January 15, 2009 Share Posted January 15, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.