是否可以使用 XSLT 对 XML 文档进行颜色编码和格式化?

发布于 2024-09-03 02:15:34 字数 58 浏览 0 评论 0原文

以前有人这样做过吗? 是否可以编写一个 XSLT 将 XML 文档转换为颜色编码、格式化的 HTML?

Has this ever been done before?
Is it possible to write an XSLT that will turn an XML document into color-coded, formatted, HTML?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

随梦而飞# 2024-09-10 02:15:34

XMLSPectrum.xsl(在 GitHub 上)是执行此操作的众多 XSLT 样式表之一 - 但这个工具专门针对 XSLT 2.0 的额外需求。

使用 XSLT 2.0,许多编程逻辑都可以位于 XPath 2.0 表达式内。因此,该产品的重点是 XPath 的格式化和着色,同时还要确保正确呈现 XSLT 指令。来自浏览器的示例屏幕截图:

在此处输入图像描述

因为 XSLT 输入被解析为文本,所以任何现有的缩进和行 -默认情况下会保留提要 - 即使在属性中也是如此(示例没有格式,因此设置了缩进选项)。与通常的 XML 格式一样,所有属性及其内容都是垂直对齐的

XMLSPectrum.xsl (on GitHub) is one of a number of XSLT stylesheets that do this - but this tool is specially for the additional demands of XSLT 2.0.

With XSLT 2.0, much of the programming logic can be within the XPath 2.0 expressions. So the emphasis for this product was the formatting and colorising of XPath - while also ensuring XSLT instructions are rendered properly also. A sample screenshot from a browser:

enter image description here

Because the XSLT input is parsed as text, any existing indentation and line-feeds are preserved by default - even in attributes (the sample had no formatting so the indent option was set). As well as the usual XML formatting, all attributes and their contents are vertically aligned

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文