我可以通过 XSLT 将控制字符放入 XML 中吗?

发布于 2024-08-04 07:12:14 字数 101 浏览 3 评论 0原文

我有以下问题:我有一个 XML 和一个 XSLT 文件来处理它并生成输出。

此过程的输出应包含控制字符“0B”。据我所知,XML 不嵌入控制字符,那么我该如何实现这一点呢?

I have the following problem: I have an XML and an XSLT file to process this it and generate output.

The output of this process should contain a control character '0B'. And as far as I know, XML doesn't embed control characters, so how can I accomplish this?

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

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

发布评论

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

评论(3

感情洁癖 2024-08-11 07:12:14

结果是 XML 文件吗?正如您所说,XML 不允许使用字符 U+000B。因此根据定义,任何包含该字符的文件都不是有效的 XML 文件。这里的大局是什么?为什么需要这个角色?您可以使用哪些替代方案?

如果您尝试创建一个文本文件作为XSLT 转换的结果,那就是另一回事了。

Is the result meant to be an XML file? As you say, XML doesn't allow character U+000B. So by definition, any file containing that character is not a valid XML file. What's the bigger picture here? Why do you need that character? What alternatives might be available to you?

If you're trying to create a text file as the result of the XSLT transformation, that's a different matter.

白芷 2024-08-11 07:12:14

在添加到 XML 文档之前,您还可以将包含 0x0B 的有效负载编码为 Base64

这将依赖于输出转换的使用者能够从 Base64 转换回原始编码。

You could also encode your payload containing 0x0B to Base64 before adding to your XML Document.

This would rely on the consumer of your output transformation being able to convert back from Base64 to the original encoding.

赤濁 2024-08-11 07:12:14

如果相关的 XML 格式支持此类字符,我希望它们驻留在某个支持 CDATA 的元素中。

你可以将你的字符放入 CDATA 部分吗? XSLT 具有用于创建 CDATA 部分 () 的构造。在内部,您可以使用 XML 实体引用对字符进行编码。

读取 XML 文件的解析器应该能够将这些实体引用转换为适当的字符。

If the relevant XML format supports such characters, I would expect them to reside in some element which supports CDATA.

Can you put your characters inside a CDATA section? XSLT has a construct for creating CDATA sections (<xsl:cdata>). Inside, you can encode your characters using XML entity references <xsl:entity-ref/>.

The parser which reads your XML file should be able to convert those entityrefs to the appropriate characters.

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