html - 传递外部 .xml 文件的内容并保留样式标签

标签 html css xml xslt

我目前正在使用以下方法将外部 .xml 文件的内容作为参数传递:

<xsl:param name="content" select="'content'" />
<p>
<xsl:variable name="getContent" select="document($content)/div" />
<xsl:value-of select="$getContent" />
</p>

并且此文件在构建期间作为输入提供:

<param name="content" expression="input/readThisFile.xml" />

在此外部 readThisFile.xml 中,某些短语用粗体标记 括起来。我想保留样式,但是当内容传递到 XSLT 并输出为 .html 时,此样式会丢失。

有什么建议吗?

最佳答案

[...] this styling is lost.

你写的是你想保留样式。但是您在显示的代码段中所做的只是获取 div 元素的 值。 的值就是:元素及其所有子元素内容的(字符串)值。

xsl:value-of 更改为 xsl:copy-of,这将保留元素,或者使用 copy idiom 进行实际处理如果您需要进一步处理内容(即过滤某些元素)。

关于html - 传递外部 .xml 文件的内容并保留样式标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25365077/

相关文章:

python - 如何使用docx库从MS Word文档中的表格中提取图像?

html - 当我使用带有 margin-top 或 margin-bottom 的 h1 或 div 时,顶部/底部出现空白

html - 使另一个div两侧的div扩展到容器的边缘

javascript - 如何让 iframe 保持其位置?

xml - JAXB:两个版本的 XSD,一种对象模型

python - 来自 GAE python 的 shopify xml 请求

javascript - Iframe 文件上传的进度条?

html - 无法让侧边菜单 scrollspy 粘在顶部

html - 如果我们在 html 和 css 代码中应用一些属性,哪个将首先应用,哪个将最终应用

css - Sass @imports 层次结构 : Bottom to top or top to bottom?