简体   繁体   English

尝试使用XSLT 2.0嵌入在HTML中包含“&gt;”子选择器的CSS <style> element

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

My file base.css contains: 我的文件base.css包含:

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 : 我尝试读取它并使用XSLT 2.0未解析文本(Saxon 9.1.0.2J)将其渲染到我的HTML输出中,如下所示:

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

However, the unparsed-text() function is converting the '>' to '&gt;' 但是,unparsed-text()函数将'>'转换为'&gt;' in the HTML, like this: 在HTML中,像这样:

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

...Which doesn't behave as "ol > li" does. ...哪个不像“ol> li”那样。

How can I use XSLT to render the '>' character into my element? 如何使用XSLT将'>'字符渲染到我的元素中? I've tried using replace(..., '&gt;', '>'), but that still renders '&gt;' 我尝试过使用replace(...,'&gt;','>'),但仍会呈现'&gt;' into the HTML. 进入HTML。

Alternatively, is there another way I can specify the CSS child selector without having to embed a literal '>' character into my HTML? 或者,是否有另一种方法可以指定CSS子选择器而无需在我的HTML中嵌入文字“>”字符?

Are you using output method XML, XHTML, or HTML? 您使用的是输出法XML,XHTML还是HTML?

The (3.0) specification says this: (3.0)规范说:

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. HTML输出方法不得对任何文本节点后代执行转义,也不得对脚本或样式元素的元素节点后代的任何属性执行转义。

So my suspicion is that you are not using the HTML output method. 所以我怀疑你没有使用HTML输出方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM