Re: [xsl] Basic Question about Adding Styles to XSL

Subject: Re: [xsl] Basic Question about Adding Styles to XSL
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 11 Jul 2006 11:17:37 -0400
Michelle,

My question is - is this the best way to do it?

You are proposing a perfectly good way to do it. Whether it is the best way depends on external factors such as how you intend to maintain your CSS (is it a benefit to do so inside the XSLT?) and whether you mind the extra bandwidth of serving it over and over again inside many pages, or would rather have recipients cache it on their systems (an advantage of out-of-line CSS). In other words, the usual CSS architecture tradeoffs.


Can I add a link to an external style sheet in the XSL?

Absolutely. From the XSL point of view, such an HTML <link/> element is just another result element, no different from any other. The HTML file that results would have to be located (statically or "virtually", if served up at request) someplace where the link resolves properly when the client looks for it; but that's not an XSLT issue either.


If you look at the HTML source code of the files served up by my XML/XSLT demo application the Sonneteer (http://www.xmlshoestring.com/Sonneteer) you'll see they call out to external CSS files, which are served up by Apache Cocoon just like the XSLT transformation results.

It's also possible to have CSS both in and out of line, again in the usual way.

Cheers,
Wendell

Current Thread