473,395 Members | 1,797 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,395 software developers and data experts.

using css in html embedded in xml rendered using xsl with javascript (phew)

Bear with me on this its a bit long.

I have some xml with a section like

<product>
<name>a great product</name>
</product>

I use javascript to parse this with an xsl template and place the
output in a <DIVin the containing html page.
All fine so far.

Now I want to highlight some special offers so I change the XML to be

<product>
<name><p style="background-color:yellow;color:red;">a great product</
p></name>
</product>

which works as long as I use the <xsl:copy-of select="name"in the
xsl.

but I don't really want to plaster this around the xml so I simplified
it to

<product>
<name><p class="specialOffer">a great product</p></name>
</product>

a created a css entry in an external style sheet of

..specialOffer
{
color: red;
background-color: yellow;
}

Again works, but I'm still not happy with this what I want is to
change it to

<product>
<name><specialOffer>a great product</specialOffer></name>
</product>

and use the css entry
specialOffer
{
color: red;
background-color: yellow;
}

but this doesn't seem to work, Why not? any ideas

Many Thanks in advance espcially if you managed to read this far

P.

May 25 '07 #1
3 2007
Oh and this works but only in mozilla not IE6
<product>
<name><specialOffer class="specialOfferStyle">a great product</
specialOffer></name>
</product>


May 25 '07 #2
"confused" <gn**********@googlemail.comwrote in message
news:11**********************@h2g2000hsg.googlegro ups.com...
Bear with me on this its a bit long.
[snipped for convenience]
and use the css entry
specialOffer
{
color: red;
background-color: yellow;
}

but this doesn't seem to work, Why not? any ideas
Yeah -- you can't create arbitrary classes on the fly (-- in IE; as you noticed
later, apparently you _can_ in Firefox. I dint know that one). Change the css
declaration to ".specialOffer" (note the period), and use it either as <p
class="specialOffer"(for entire paragraphs) or as <span class="specialOffer">
(as a text attribute).
Verbosity is not a problem since you can add these attributes using the XSL.

[Jongware]
May 25 '07 #3
confused wrote:
Oh and this works but only in mozilla not IE6
<product>
<name><specialOffer class="specialOfferStyle">a great product</
specialOffer></name>
</product>

since you are using xsl anyway why not just generate the standard html
+css that you said worked earlier rather than a mixture if html and
your own xml markup?

adding a template like

<xsl:template match="specialOffer">
<div class="specialOffer">
<xsl:apply-templates/>
</div>
</xsl:template>
should be all you need, together with the css that styles div.specialOffer
--
<a href="http://dpcarlisle.blogspot.com">David</a>
May 25 '07 #4

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

Similar topics

10
by: Andrew Poulos | last post by:
While this works on IE 6: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>aiff</title> <meta http-equiv="Content-Type"...
8
by: otto | last post by:
Hi, all: I have a problem with the inclusion of .js files in mu .aspx pages when using Master Pages. I try to explain it. If I make a web project without master pages I simply put in the head...
2
by: Ed Jay | last post by:
I generate several string in a js. I output the strings to an invisible container using inner.HTML. Then, the container is made visible. For layout purposes, I want to precede some of the strings...
4
by: Jeremy Chapman | last post by:
I'b developing a web app to be viewed on various mobile devices, and I want the app to be as light as possible. I noticed that some of my pages have a link to the embedded resource webforms.js in...
3
by: SMH | last post by:
Normally an SVG document is loaded/parsed/interpreted inside an HTML document using an 'object' (or 'embed') element, although there are supposedly other ways too. The problem is, the SVG document...
13
by: lister | last post by:
If I want to move something to a new line, should I be using <br/>, or is there a way of doing it in CSS? I was just thinking if it was possible in CSS then it would be better as otherwise the...
3
by: T0mm0 | last post by:
I'm using a WYSIWYG HTML editor that supports vertical and horizontal scrolling. I want to limit the area that users can edit. My editor doesn't support this so I need to come up with some way to...
18
by: Dan | last post by:
Hi, There is a detailsview which contains a textbox in editmode. How to get the id of the textbox in javascript? I tried this: <asp:DetailsView ID="DetailsView1" runat="server" >...
10
dj12345
by: dj12345 | last post by:
Hi, (Asp.net + Ajax) I am creating a page which will fetch data from server without postbak of a page.. I have 2 controls on this page TextBox and Lable. I have assigned TextBoxWatermark...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.