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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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>

   
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.