LinuxQuestions.org
Help answer threads with 0 replies.
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 01-03-2008, 03:00 AM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
setting XML attribute using parameter in XSLT


Hi,

I'm trying to assign the value of an XSL parameter to the attribute field of the input element.

If I do like this:
PHP Code:
<input type="text" name="title" value="<xsl:value-of select='$title_value'></xsl:value-of>"/> 
It tells me that < and > cannot be inside the attribute element. So I changed it like this:

PHP Code:
<input type="text" name="title" size="60" value="&lt;xsl:value-of select='$title_value'&gt;&lt;/xsl:value-of&gt;"/> 
But this time, it doesn't give me the value of parameter, instead it prints whole thing as a string.

Any idea how to set the attribute value of the input element to the value of the parameter?
 
Old 01-03-2008, 07:31 AM   #2
delirio
LQ Newbie
 
Registered: Jan 2008
Location: London
Distribution: RH 8.0, Fedora 4.0, SuSe 9.1
Posts: 2

Rep: Reputation: 0
XSL Attribute values

[HTML]<input type="text" name="title" size="60" value="{$title_value}"/>[/HTML]

the above should output the data value of the parameter $title_value to the output data value of input/@value.

This will work if you know for sure the parameter $title_value is allways populated, or you don't care if the attribute input/@value is empty.

If you do care, you should use the following syntax:
[HTML]
<input ...>
<xsl:attribute name="value">
<xsl:choose>
<xsl:when test="string-length($title_value) &gt; 0">
<xsl:value-of select="$title_value"/>
</xsl:when>
<xsltherwise>some other value</xsltherwise>
</xsl:choose>
</xsl:attribute>
</input>
[/HTML]
 
Old 01-03-2008, 04:03 PM   #3
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
I really appreciate your help. It was exactly what I was looking for. Thanks a lot.
 
  


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
LXer: Expand OpenOffice with XSLT and rich text XML LXer Syndicated Linux News 0 10-11-2007 11:30 PM
XSLT transformation of XML document using XMLNS Foomajick Programming 7 10-25-2006 05:27 AM
LXer: Update Your XML with XSLT, Apache Ant, and Java SE LXer Syndicated Linux News 0 08-24-2006 07:54 PM
XSLT/xml enforcing full tag syntax bigearsbilly Programming 2 11-23-2005 02:38 AM
ePlease help-> XML, XSLT James Clarkes XT software Al Bundy Linux - Software 0 04-21-2003 06:49 AM

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

All times are GMT -5. The time now is 01:32 PM.

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