views:

24

answers:

3

how do i implement css in xsl file? i tried this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
<link rel="stylesheet" type="text/css" href="dxsl.css"/>
<xsl:output method="html" />

but it threw the error:

XSLTProcessor::importStylesheet(): Found a top-level element link with null namespace URI 

and

Warning: XSLTProcessor::transformToXml(): No stylesheet associated to this object 
A: 

'link' is a HTML element and you're trying to use it as an XML one. XSL modifies input into another document. You don't use CSS in an XSL file. You insert it into an (X)HTML file and apply it there.

Rob
thanks, but i got it working. it has to be just after the head element in the xsl file. `http://www.velocityreviews.com/forums/t166257-linking-to-a-separate-css-in-xsl.html`
fuz3d
Yes, because, once inside the head, you are in the HTML namespace.
Rob
+1  A: 

this link helped.

fuz3d
A: 

If I understand you correctly, you wish for the output to have a particular stylesheet?

XSL is a language used to transform XML from one format to another (in a sense it's like applying a css stylesheet). What would happen in a typical use case is that you would take some xml file and use XSL to transform it, say to XHTML. In this output, you can include a stylesheet using the link element if you wanted, but XSL doesnt really make use of CSS as such. (So basically, try putting the CSS in the XSL as part of the transformation to have the XHTML output use it.)

If this is an XML document you simply need to include the reference to the XSL and it should handle the transformation for you automatically.

cm2