使用 xsl 转换创建文档时忽略无效的 xml
有一个 java 工具,它使用多个 xsl 转换将数据从 crx 转换为 esi xml 标记。
通常,ESI 标记是无效的 xml,因为 ESI 通常是小逻辑片段,并不总是具有相同的开始和结束标记。 例如:
<esi:assign>
bunch of esi logic
<esi:vars>$(myVar)</esi:vars>
java xsl 引擎当前不允许生成无效的 xml。因此,我们必须将所有 esi 输出包装在虚拟标签中,但这会导致几个问题。
所以我想知道是否有一种方法可以允许 java xsl 转换引擎生成无效或格式不正确的标记?
谢谢。
there is a java tool that uses several xsl transforms to convert data out of crx into esi xml markup.
often esi markup is non valid xml because esi is often small snippets of logic that do not always have the same opening and closing tags.
ex:
<esi:assign>
bunch of esi logic
<esi:vars>$(myVar)</esi:vars>
the java xsl engine currently does not allow xml to be generated if it is invalid. Because of this we have to wrap all esi output in dummy tags but this causes several problems.
So I am wondering if there is a way to allow java xsl transform engine to generate invalid or not well formed markup?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将输出模式设置为
text
(而不是默认的xml
)。现在,您可以生成任何类型的文本(即使它看起来很像 XML),但您必须自己确保像<
、>
、等在正确的地方正确转义。此外,由于显而易见的原因,像
xsl:element
这样的东西将不再起作用。也许用真正的编程/脚本语言编写这样的东西比用 XSL 更好。
Set the output mode to
text
(instead of the defaultxml
). Now, you can generate any kind of text (even if it looks a lot like XML) but you have to make sure for yourself that characters like<
,>
, etc. are properly escaped in the right places.Also things like
xsl:element
won't work anymore for obvious reasons.Maybe you're better off writing things like that in a real programming/scripting language than in XSL.
如果您可以更改 xsl 转换,则可以使用:
If you can alter the xsl transforms, you can use :