homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

Calling an XSLT Variable into a css ducument

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


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;


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)

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?



 9:58 am on Feb 21, 2003 (gmt 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! :)



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

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.



 3:44 pm on Feb 21, 2003 (gmt 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)

Thanks Choster,

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved