473,657 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSL: putting a XSL value inside an html attribute?

I can't figure out how to do this because the tags have to be properly
nested... and I dont have much XSL experience. Say I'm generating an
HTML tag in my XSL file, and for one of it's attributes, I want to put
the value of an XSL tag... for example:

XSL file...
......
<xsl:template match="/"
<div class = "{value of XSL tag 'entry' goes here}" > hello
world</div>
</xsl:template>

how would I do this?
thanks in advance

May 17 '06 #1
6 1971
I presume you actually meant
<div class = "{value of XSL tag 'entry' goes here}"> hello world</div>

The question is: What do you mean by "value of XSL tag 'entry'"?
Depending on what value you're actually trying to obtain, you may be
able to use an Attribute Value Template as here, or you may need to use
<xsl:attribut e> to create this attribute.
May 17 '06 #2
well yea my example up there wasnt accurate:D. My xml file is like
this:

<entry>
<type>128</type>
</entry>
<entry>....</entry
<entry>....

so in the XSL file, I have a template that looks at each 'entry' tag
and creates an html DIV tag for it. As the div tag is created, I want
the 'type' tag (inside each entry) to be used as its class name.
is that more clear??
so for the first entry above, it would create something like

<div class="128">som e text here</div>

May 17 '06 #3
Sounds like what you want is something like

<xsl:template match="entry">
<div class="{type}"> some text here</div>
</xsl:template>

or

<xsl:template match="entry">
<div>
<xsl:attribut e name="class">
<xsl:value-of select="type"/>
</xsl:attribute>
<xsl:text>som e text here</xsl:text>
</div>
</xsl:template>
May 17 '06 #4
BTW, the xsl:text in the second version was mostly for readability; I
could have written it as

<xsl:template match="entry">
<div>
<xsl:attribut e name="class">
<xsl:value-of select="type"/>
</xsl:attribute>s ome text here</div>
</xsl:template>

but that would tend to obscure the intent.
May 17 '06 #5
oh wow I didnt know it'd be that simple thanks! I'll try it out.

So the second example that you have... does that actually put the
attribute inside the div tag?

May 17 '06 #6
Kourosh wrote:
I can't figure out how to do this because the tags have to be properly
nested... and I dont have much XSL experience. Say I'm generating an
HTML tag in my XSL file, and for one of it's attributes, I want to put
the value of an XSL tag... for example:
See http://xml.silmaril.ie/authors/makeup/
XSL file...
.....
<xsl:template match="/"
<div class = "{value of XSL tag 'entry' goes here}" > hello
world</div>
</xsl:template>

how would I do this?


<div class="{entry}" >

But that presupposes that "entry" is a child element of the context
node. If "entry" is somewhere else in the document, you have to give
the XPath to it.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
May 17 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1880
by: Jyrki Keisala | last post by:
I have an XML file: <document> <record> <element1>Text</element1> <element2>More text</element2> <element3>Even more text</element3> <element4>Some text <link><title>Google</title><url> http://www.google.com</url></link> with a link.</element4>
1
1892
by: Philip | last post by:
Hi, I am trying to output certain nodes inside another. I have an xml template with field definitions for a form, and this includes textfields, labels, checkboxes etc plus fieldssets. I defined them like this: >>>> XML SNIPPET >>>> <fields>
2
1965
by: Burt Lewis | last post by:
Hi, I have 2 xsl style sheets calling separate rss feeds and I use ASP to display. Problem is that the 1st xsl takes on the style of the 2nd xsl even though they are different formats. I think I need to clear from memory but not sure how. This is the code and sample outputs. They work great on their own but when I call them both they display the same formats. Thanks for any help.
1
3279
by: j erickson | last post by:
with the following xsl and xml file, the display of the gif file with the <image/url> tag works. However, the gif file in the <description> tag using the name attribute "src" won't make the correct link to the gif file. why? <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
2356
by: Sebastian Kerekes | last post by:
Greetings, I'm developing an application that supports multiple languages. In my XSL I use variables to place the text where it belongs to. At the top of the document I include those variables - the included file depends on the language. Atm I'm editing those file manually. Luckily atm it's only two languages I have to work with, but even in this case I forget to add a variable that I added in the other file, forget to use entities .....
1
15081
by: Matt | last post by:
For example, how to represent hyperlink in XSL? I want to add hyperlink in XSL. i.e. I need to generate <A HREF="http://mypage.html">home page</A> in HTML. I tried the following approaches but still not work, it don't display anything Approach #1: direct link, not work A) double quote, <A HREF="<xsl:value-of select="/bio/homepage" />">home page</A> OR B) single quote, <A HREF='<xsl:value-of select="/bio/homepage" />'>home page</A>
0
1497
by: james | last post by:
Hi there! I'm trying to convert an HTML file to CSS and I have problems reading the CSS attributes. For example: for table attribute: <xsl:attribute-set name="table.data"> <xsl:attribute name="table-layout">fixed</xsl:attribute> <xsl:attribute name="space-before">10pt</xsl:attribute>
2
2388
by: lievemario | last post by:
I have made a perl script witch gets information out of a database, transfers it into an xml-file file and than I parse this to a html document using xsl. The problem is dat the html doc needs a parameter which can be found in the xml file. I've done something like <xsl:variable name="id" select="person_id"/> <a href="http://localhost/CGI/detailsselection.cgi?ID=$id"><xsl:value-of select="name"></xsl:value-of><xsl:value-of...
3
8472
by: Ofay | last post by:
I am trying to do a mouseover with tooltips with an XSL stylesheet. I want to be able to pick data from the XML using the syntax <xsl:value-of select="CHALLENGE_REMARKS"/> How do I send the data from this element to the doToolTip function. Ex. <td> onmouseover="doTooltip(event,<xsl:value-of select="CHALLENGE_REMARKS"/>) </td> This does not work. I have tried putting the element in a var and
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.