[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: include css in xsl

Subject: RE: include css in xsl
From: "Robert Koberg" <rob@xxxxxxxxxx>
Date: Wed, 19 Mar 2003 09:19:12 -0800
include css
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:  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:  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


Current Thread
  • RE: include css in xsl
    • Passin, Tom - Wed, 19 Mar 2003 10:27:59 -0500 (EST)
      • <Possible follow-ups>
      • Passin, Tom - Wed, 19 Mar 2003 11:20:50 -0500 (EST)
        • TP - Wed, 19 Mar 2003 11:49:12 -0500 (EST)
          • Robert Koberg - Wed, 19 Mar 2003 12:17:26 -0500 (EST) <=
          • TP - Thu, 20 Mar 2003 10:10:55 -0500 (EST)
          • Robert Koberg - Thu, 20 Mar 2003 10:29:46 -0500 (EST)
          • TP - Thu, 20 Mar 2003 10:22:24 -0500 (EST)
          • Karl Stubsjoen - Wed, 19 Mar 2003 13:03:04 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.