Subject: Re: [xsl] include css in xsl - follow up From: "TP" <tpass001@xxxxxxxxxxx> Date: Thu, 20 Mar 2003 09:16:20 -0600 |
I got the xsl to pick up the css and have declared the css file as a link in hte xsl file as <xsl:template match="message/text/dTree"> <html> <head> <link rel="stylesheet" href="../css/style.css" type="text/css" /> <script language="JavaScript" type="text/javascript" src="../js/tree.js"/> </head> <body> <xsl:call-template name="menuTree"/> </body> </html> </xsl:template> <xsl:template name="menuTree"> etc....... </xsl:template> My observation here is that the template menuTree does not inherit the css properties from the calling template. Is that expected? Whats the solution to this. Thanks. TP. > Hi, > > A couple of things: > > 1. You do realize that anything behind WEB-INF (in a servelet container) is > protected. That is, it is not available to the client. > > 2. You are using backslashes when you should be using forward slashes: > href="../css/style.css" > > Solution: > > Put your CSS folder in your docroot and reference by a root relative path: > > href="/css/style.css" > > you can still use relative paths (perhaps you want to generated pages offline?) > by figuring out where your transformation places the rendered version in your > server's path. I assume you are using a servlet - so you can see what the > url-pattern is and assume that is where your rendered version is in relation to > the CSS. > > For example, if you have: > > <servlet> > <servlet-name>Blah</servlet-name> > <servlet-class>com.Blah</servlet-class> > <load-on-startup/> > </servlet> > <servlet-mapping> > <servlet-name>Blah</servlet-name> > <url-pattern>/Blah</url-pattern> > </servlet-mapping> > > in a webapp that is living off of: > > http://myserver.com/myapp > > you would need a style href like the following: > > root relative - href="/myapp/css/style.css" > document relative - href="css/style.css" > > best, > -Rob > > > > -----Original Message----- > > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of TP > > Sent: Wednesday, March 19, 2003 8:55 AM > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: Re: [xsl] include css in xsl > > > > > > Thanks Passin and Blix (interesting name) > > > > This is the xsl below > > ================================================== > > <?xml version="1.0" encoding="UTF-8"?> > > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > xmlns:lxslt="http://xml.apache.org/xslt" > > xmlns:counter="MyCounter" > > extension-element-prefixes="counter" > > version="1.0"> > > > > <xsl:output method = "html" /> > > <xsl:template match="message"> > > <html> > > <head> > > <link rel="stylesheet" href="..\css\style.css" type="text/css" > > media="screen"/> > > </head> > > <body> > > etc... > > </body> > > </html> > > </xsl:template> > > </xsl:stylesheet> > > ================================================== > > > > the filesystem is as > > WEB-INF > > -- classes > > -- lib > > -- xslt > > ---- this.xsl > > -- css > > ---- style.css > > > > This is a subset of the entire stylesheets. The reason I am saying that is > > because my stylesheets use templates and include/import other stylesheets > > which are getting resolved properly. I use the implement URIResolver in my > > servlet so that the files are picked up from the appropriate folder. > > > > You know those errors which you think are nothing but take a long time to > > resolve but end up being something small. this cud be one of them. > > > > I appreciate the help. > > > > Thanks. > > > > TP. > > ----- Original Message ----- > > From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> > > To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > > Sent: Wednesday, March 19, 2003 10:23 AM > > Subject: RE: [xsl] include css in xsl > > > > > > > [ I have copied this question over to the right thread. Please respond > > > to this thread] > > > > > > It sounds as if you are expecting something to happen that is not going > > > to happen. the html code you show below is apparently in an html file > > > (the output of your transformation, I imagine?). At this point, when > > > you load the file into a browser, no xslt transformation is going to be > > > invoked. On the other hand, the css stylesheet should be applied to the > > > page, via the "link" element. > > > > > > If that is not happening, probably the path to the css file is wrong, or > > > the css file is not valid css. Perhaps the external css file contains > > > xml instead of css (it should not have a "style" element, for example)? > > > > > > You have to decide whether your xslt stylesheet is going to insert the > > > __css text__ from an xml file into your html output document, or whether > > > it is going to insert a reference to a css file, as you have it below. > > > You cannot succees with a mix and match approach. > > > > > > Cheers, > > > > > > Tom P > > > > > > > > [ TP] > > > > > > I wrote this in the head of the xsl > > > > > > ---------------------------------------------------------------- > > > > > > <head> > > > > > > <link rel="stylesheet" href="style.css" type="text/css"/> > > > > > > </head> > > > > > > ---------------------------------------------------------------- > > > > > > It did not pick it up..... any ideas..... > > > > > > > > > > > > > > > > What do you mean? What do you mean by "the head of the xsl"? > > > > > > > > This is the code that apears in "View source" > > > > > > > > <html> > > > > <head> > > > > <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> > > > > <title>Test</title> > > > > <link media="screen" type="text/css" href="../css/style.css" > > > > rel="stylesheet"> > > > > </head> > > > > <body> > > > > etc.... > > > > > > > > I dont belive that the xsl is picking up the css file when it > > > > renders the > > > > html. > > > > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] include css in xsl, TP | Thread | RE: [xsl] include css in xsl - foll, Robert Koberg |
Re: [xsl] include css in xsl, TP | Date | RE: [xsl] Answers to review questio, Americo Albuquerque |
Month |