Css in xsl document

cssxslt

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">
<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 

Best Answer

Your html (link tag) must be inside an xsl:template. The xsl:template must be inside an xsl:stylesheet.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" />

<xsl:template match="/*//*[1]">

    <link rel="stylesheet" type="text/css" href="dxsl.css"/>

</xsl:template>

</xsl:stylesheet>