473,385 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1957
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:attribute> 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">some 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:attribute name="class">
<xsl:value-of select="type"/>
</xsl:attribute>
<xsl:text>some 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:attribute name="class">
<xsl:value-of select="type"/>
</xsl:attribute>some 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
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>...
1
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...
2
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...
1
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...
8
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 -...
1
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...
0
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...
2
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.