LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2011, 08:12 PM   #1
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Rep: Reputation: 53
testing xslt parameters


Hi. I'm trying to find a means to run a simple xsl:if test in xslt, which when true, will set a value I can use in the output of the xslt stylesheet.

I found a somewhat relevant discussion, but I'm not sure of the accuracy of the following excerpt because the method doesn't work when I use it in another context:

Quote:
I must admit at this point, that I have just realised the code I provided in my first post does work...

<xsl:if test="$page = 1">
do some tranformation
</xsl:if>

This is at: http://www.webmasterworld.com/forum26/235.htm
Although I'm not running a transformation inside the tags. I'm assigning values to some new parameters: eg,

PHP Code:
<xsl:param name="he_she">he</xsl:param
I appreciate your help.

Last edited by bluegospel; 09-23-2011 at 08:13 PM. Reason: revise obscure language
 
Old 09-25-2011, 05:52 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
I wrote an app some years ago which generated xml data which was marked up by an xslt, I don't remember having any issues with xsl:if but I'll check when I get home and post a sample.
 
Old 09-25-2011, 09:33 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Here is an xslt test I have in some of my code where I check for a non-null value.
Code:
<xsl:if test="col[@field='level']!=''">
   <data field="level"><xsl:value-of select="col[@field='level']"/></data>
</xsl:if>
The col[@field='level'] would I suspect be equivalent to your $page

Hope that helps.
 
Old 09-25-2011, 09:51 PM   #4
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
Quote:
Originally Posted by graemef View Post
Here is an xslt test I have in some of my code where I check for a non-null value.
Code:
<xsl:if test="col[@field='level']!=''">
   <data field="level"><xsl:value-of select="col[@field='level']"/></data>
</xsl:if>
The col[@field='level'] would I suspect be equivalent to your $page

Hope that helps.
Thanks graemef. Either because I'm a newbie or very tired, or both, I don't quite understand what: col[@field='level'] is. I'll look at this again tomorrow. Thanks again!
 
Old 09-25-2011, 10:03 PM   #5
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
The col[@field='level'] is just taken from my input file I have a col tag <col> with a param field with a value of field, thus <col field='level'></col> or <coll field='level'>L0</col> and I want to end up with <data field='Level'>L0</data> if and only if I have a non null value in the first example.
 
Old 09-26-2011, 05:17 AM   #6
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Sorry I lied, must have been a different app I was thinking of - this one only has xsl:when :-

Code:
...
<xsl:when test="contains(job_status, 'No Data')">
	<tr bgcolor="#EE6633">
		<td><xsl:value-of select="server_name"/></td>
		<td><xsl:value-of select="job_name"/></td>
		<td><xsl:value-of select="job_status"/></td>
		<td><xsl:value-of select="start_date"/></td>
		<td><xsl:value-of select="time_started"/></td>
		<td><xsl:value-of select="bytes_processed"/></td>
		<td><xsl:value-of select="elapsed_time"/></td>
		<td></td>
	</tr>
</xsl:when>
...
 
Old 09-27-2011, 12:58 PM   #7
bluegospel
Member
 
Registered: Jan 2010
Distribution: centOS
Posts: 404

Original Poster
Rep: Reputation: 53
I've not forgotten this issue. I'm kind of pressed with others right now. I will certainly return to this soon.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Icecast and xslt-config problem tuxrules Linux - Newbie 6 08-13-2010 06:28 AM
xquery or XSLT? mohtasham1983 Programming 3 12-17-2007 06:06 AM
LXer: The Basics of XSLT LXer Syndicated Linux News 0 01-27-2007 11:54 AM
Command-line XSLT translator Spudley Programming 3 04-18-2005 03:01 PM
Installing xslt pk21 Linux - Software 0 09-15-2003 10:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration