Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css in xsl document

Tags:

css

xslt

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 
like image 780
input Avatar asked Jul 31 '10 13:07

input


People also ask

Can you use CSS in XSL?

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.

Can you use CSS with XML?

CSS can be used to display the contents of the XML document in a clear and precise manner. It gives the design and style to whole XML document. Define the style rules for the text elements such as font-size, color, font-weight, etc.

What is the advantage of CSS over XSL?

The reason is that CSS is much easier to use, easier to learn, thus easier to maintain and cheaper. There are WYSIWYG editors for CSS and in general there are more tools for CSS than for XSL. But CSS's simplicity means it has its limitations.

How is XSL different from CSS?

XSL is used to refer to a family of languages used to transform and render XML documents. CSS is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language. Hence XSL and CSS are not the same and not interchangeable.


1 Answers

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>
like image 131
Jason Williams Avatar answered Oct 17 '22 05:10

Jason Williams