Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 10th, 2008, 08:45 AM
Registered User
 
Join Date: Jul 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conditional transformation

Hello:

I am a novice to XSLT. Actually, this is my first try at it.

Problem 1:
In my XML document, I have two elements:

<receivedateformat>102</receivedateformat>
<receivedate>20080401</receivedate>

Depending on the value of the receivedateformat, I would like to display receivedate in multiple formats.

In the above example, I would like to format it as 04/01/2008.

Problem 2:
Another element I have is <serious>1</serious>. I would like to transform value to a more meaningful text. In this example, the "1" will have to translated to say "Yes".

Can somebody tell me how I can do this?

venki

Venki
 
Old July 10th, 2008, 08:48 AM
Registered User
 
Join Date: Jul 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using XML SPY's Stylesheet Designer to create the XSLT.

I see the following fragment:

<xsl:for-each select="messageformatversion">
     <xsl:apply-templates />
</xsl:for-each>

I guess the <xsl:apply-templates /> is responsible for plaing the value of messageformatversion on the pag that is being generated?

Venki

Venki
 
Old July 10th, 2008, 08:50 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well you probably want to start by investigating the xsl:if instruction.

A good web site to start reading up on these things is http://www.w3schools.com/xsl/default.asp

/- Sam Judson : Wrox Technical Editor -/
 
Old July 10th, 2008, 09:09 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's not a good idea to post three unrelated questions on the same forum thread. It just gets everyone confused.

You do say you're a novice, but you don't say what you have read and what you have tried, so it's very hard to see where you are stuck and what it is that you haven't yet understood. To be honest, your posts give the impression that you haven't yet done much reading or study of the language. I would recommend that your first step in learning any new language should be to spend four hours with a good book; after that, you can start asking questions about the things you haven't understood.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
using transformation KieshaJ310 ASP.NET 2.0 Basics 2 June 6th, 2007 05:56 AM
conditional IF roy_mm Reporting Services 0 October 30th, 2006 07:52 AM
Transformation Question realgone_ SQL Server DTS 1 March 3rd, 2005 10:22 PM
XSL transformation Thodoris XML 0 May 20th, 2004 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.