This is the mail archive of the docbook-apps@lists.oasis-open.org mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [docbook-apps] embedding contents of external css stylesheet


On Sun, Sep 21, 2003 at 09:18:36AM -0400, Denis Bradford wrote:
> I would like to embed the contents of an external css stylesheet at
> user.head.content. That is, instead of a link to the stylesheet (a la
> html.stylesheet), I would like a document-level <style> block in the
> head of the document. I want to pull the css rules in from an external,
> shared file, rather than hardwiring them in the stylesheet.
> 
> Anybody know how to do this? btw, the idea here is that the generated
> html file can be moved around and viewed standalone - the external css
> file is not always convenient.

Add this to your customization layer:

<xsl:template name="output.html.stylesheets">
  <xsl:variable name="style" select="document($html.stylesheet)"/>
  <xsl:copy-of select="$style"/>
</xsl:template>


The template named 'output.html.stylesheets' handles
the $html.stylesheet parameter when it is set.
In this case, instead of outputting a <link>
element, it copies the stylesheet file into
a variable and outputs the variable's contents.

The catch is that you have to add <style> tags to
your css file:

<style type="text/css">

[css stuff here]
...

</style>

That's because the document() function can only open
XML files, so there must be start and end tags.
But that is ok, since you want the styles to be enclosed
in <style> tags in the HTML anyway.

-- 

Bob Stayton                                 400 Encinal Street
Publications Architect                      Santa Cruz, CA  95060
Technical Publications                      voice: (831) 427-7796
The SCO Group                               fax:   (831) 429-1887
                                            email: bobs@sco.com

To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]