Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to use XSLT 2.0 to embed CSS that contains '>' child selector in HTML <style> element

Tags:

html

css

xslt

My file base.css contains:

ol > li { color: red; }

I try to read it and render it into my HTML output using XSLT 2.0 unparsed-text (Saxon 9.1.0.2J) like this :

<style>
  <xsl:sequence select="unparsed-text(fn:iri-to-uri($CSS-BASE-FILE))"/>
</style>

However, the unparsed-text() function is converting the '>' to '&gt;' in the HTML, like this:

<style>
ol &gt; li { color: red; }
</style>

...Which doesn't behave as "ol > li" does.

How can I use XSLT to render the '>' character into my element? I've tried using replace(..., '&gt;', '>'), but that still renders '&gt;' into the HTML.

Alternatively, is there another way I can specify the CSS child selector without having to embed a literal '>' character into my HTML?

like image 322
Cary Millsap Avatar asked Nov 21 '13 00:11

Cary Millsap


1 Answers

Are you using output method XML, XHTML, or HTML?

The (3.0) specification says this:

The HTML output method MUST NOT perform escaping for any text node descendant, nor for any attribute of an element node descendant, of a script or style element.

So my suspicion is that you are not using the HTML output method.

like image 191
Michael Kay Avatar answered Oct 29 '22 13:10

Michael Kay