Welcome to WebmasterWorld Guest from 50.19.57.50

Forum Moderators: not2easy

Message Too Old, No Replies

Calling an XSLT Variable into a css ducument

     
10:36 pm on Feb 20, 2003 (gmt 0)

New User

10+ Year Member

joined:Apr 29, 2004
posts:3
votes: 0


Hey,

I am currently working with CSS to style XSLT documents, which are basically xhtml pages combined with xsl code. Anyway, in XSL you can create a variable with this code;

<xsl:variable name="imageDir" select="'imagePath'" />

You can then call this variable anywhere in you xslt document with the code;

{$imagePath}

An example of using this would be:

<img href="{$imageDir}/imageone.gif" /> which would yield the code <img href="imagePath/imageone.gif" /> to the browser.

So I am trying to pull this variable into my CSS stylesheet like so;

.table { background-image: url('{$commonImages}key.gif); }

However the CSS stylesheet is having a problem with the '{}' characters inside the declaration.

Any ideas?

8:35 am on Feb 21, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 4, 2002
posts:5044
votes: 0


Hi, Welcome to WebmasterWorld! [webmasterworld.com]

I'm afraid I know next to nothing on XSLT other than it annoys me that I've never experimented with it ;)

Any XML/XSLT experts out there?

Nick

9:58 am on Feb 21, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member suzyuk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Oct 1, 2002
posts:5199
votes: 0


I'm no expert either but have started "experimenting" when time permits

My best guess is that you need to write your stylesheet as an XML document then somehow transform it, server side, so the browser interprets it as a CSS document.

I found this [xmlfiles.com] which may help..

or it could it be simply saving your stylesheet with an xml extension and changing the <link rel> or @import link in the head of you document?

Sorry if this is rubbish..but hey gotta start somewhere! :)

Suzy

2:42 pm on Feb 21, 2003 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Mar 31, 2002
posts:7575
votes: 0


jjones,
Welcome to WebmasterWorld!

I'm not an expert when it comes to XSL but I'll take a shot at it.

I assume know that XSL in Internet Explorer 5 is NOT compatible with the official W3C XSL Recommendation.

I also assume the missing single quote in your example is a typo (?).

According to the W3C curly braces are not recognized recursively inside expressions. SO in your example of { background-image: url('{$commonImages}key.gif); } I think all you would need to do is to remove the inner curly braces, and add that single quote and you should be good to go. Try it and let us know.

[w3.org...]

3:44 pm on Feb 21, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 17, 2001
posts:1262
votes: 0


I don't think the problem here is the CSS-- by the time the browser "gets to" the CSS, the XSL engine ought to have already interpreted the variable. So somewhere, this value is not being found.

Have you tried explicitly calling the variable using xsl:value-of? This code works for me:


.table { background-image: url('
<xsl:value-of select="$commonImages" />
key.gif'); }

Please be sure to double-check the code for typos as well.

8:27 pm on Feb 21, 2003 (gmt 0)

New User

10+ Year Member

joined:Apr 29, 2004
posts:3
votes: 0


Thanks Choster,

I never even thought of doing that. I'll try that and let you all know if it works...

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members