XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Sushant PrabhuSubject: replace decode style functionality
Author: Sushant Prabhu
Date: 08 Jan 2007 08:12 PM
Hi All

Currently I am receiving some ids to my functionality as <xsl:param name="type_id"/>

so the id's are like 1,2,3, & so on

I print the same using <xsl:value-of select="$type_id"/>
Now i want to do something like this
if the id is 1 it should translate to a string called 'Continent'
if the id is 2 it should translate to a string called 'Country'
if the id is 3 it should translate to a string called 'State'
if the id is 4 it should translate to a string called 'City'

was looking if we have a functionality similar to decode where i can say something like this
<xsl:value-of select="function($type_id,'1','Continent','2','Country','3',
'State','4','City')"/>

Looking out for some functionality on the same lines.

Do post your thoughts on the same


Regards,


Posttop
Minollo I.Subject: replace decode style functionality
Author: Minollo I.
Date: 08 Jan 2007 09:50 PM
If you want to do that in XSLT, you need to use <xsl:choose>; you can encapsulate in a template or in a function (if using XSLT 2.0). You would need to do something like...
<xsl:choose>
<xsl:when test="$type_id = '1'">Continent</xsl:when>
<xsl:when test="$type_id = '2'">Country</xsl:when>
...
<xsl:otherwise>some default</xsl:otherwise>
</xsl:choose>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.