什么会导致 Orbeon 在 XHTML 模式下生成重复的 xmlns:xbl 前缀?
我正在开发一个嵌入 Orbeon XForms 渲染器的应用程序。我用它来生成 XHTML 而不是 HTML。我们有一个使用 2 个自定义 XBL 组件的表单。
我们传递给 orbeon 的 XHTML 似乎是正确的。但是 Orbeon 生成的 XHTML 在 元素上包含两次 xbl 命名空间的定义。这会阻止它被解析为有效的 XML。
这实际上是一个非常复杂的形式,我无法在这里发布,但这个问题的重要部分是:
<xhtml:html
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:fw="http://orionhealth.com/forms/widgets" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:head>
<!-- Lots of stuff -->
<xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl">
<xbl:script src="...."/>
<xbl:binding id="fw-autocomplete" element="fw|autocomplete">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
</xbl:xbl>
<xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl">
<xbl:script src="...."/>
<xbl:binding id="fw-datetime" element="fw|datetime">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
<xbl:binding id="fw-date" element="fw|date">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
<xbl:binding id="fw-partial-date" element="fw|partial-date">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
</xbl:xbl>
</xhtml:head>
<xhtml:body id="body">
<!-- Lots of stuff -->
</xhtml:body>
</xhtml:html>
值得注意的是,虽然定义了两个 XBL 组件,但它们都没有在文档正文中实际使用。 Orbon 生成的 XHTML(再次简化)为:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:fw="http://orionhealth.com/forms/widgets"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xxforms:noscript="true">
<head>
<!-- Lots of Stuff -->
</head>
<body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:xbl="http://www.w3.org/ns/xbl"
id="body"
class="yui-skin-sam">
<!-- Lots of Stuff -->
</body>
</html>
请注意 body 标记上重复的 xmlns:xbl="http://www.w3.org/ns/xbl"
。
谷歌搜索我没有找到任何有关此问题的信息,有谁知道会导致此问题的原因以及我可以采取哪些措施来解决它?
我注意到,如果我在
元素而不是每个
元素上定义 xbl 前缀,这似乎不是这是一个问题,Orbeon 生成的 XHTML 仅在
元素上定义了一次此前缀。
I'm working on an application that embeds Orbeon XForms renderer. I'm using this to generate XHTML rather than HTML. We have a form that uses 2 custom XBL components.
The XHTML that we pass to orbeon is appears to be correct. But the resulting XHTML from Orbeon contains the definition of the xbl name-space on the <body>
element twice. This prevents it being parsed as valid XML.
This is actually a very complex form which I can't post here but the important bits for this question are:
<xhtml:html
xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:fw="http://orionhealth.com/forms/widgets" xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:head>
<!-- Lots of stuff -->
<xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl">
<xbl:script src="...."/>
<xbl:binding id="fw-autocomplete" element="fw|autocomplete">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
</xbl:xbl>
<xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl">
<xbl:script src="...."/>
<xbl:binding id="fw-datetime" element="fw|datetime">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
<xbl:binding id="fw-date" element="fw|date">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
<xbl:binding id="fw-partial-date" element="fw|partial-date">
<xbl:template>
<!-- Lots of stuff -->
</xbl:template>
</xbl:binding>
</xbl:xbl>
</xhtml:head>
<xhtml:body id="body">
<!-- Lots of stuff -->
</xhtml:body>
</xhtml:html>
Of note, while both of the XBL components are defined, neither of them is actually used in the body of the document. The resulting XHTML from Orbon (again simplified) is:
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:exf="http://www.exforms.org/exf/1-0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:fw="http://orionhealth.com/forms/widgets"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xxforms:noscript="true">
<head>
<!-- Lots of Stuff -->
</head>
<body xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:xbl="http://www.w3.org/ns/xbl"
id="body"
class="yui-skin-sam">
<!-- Lots of Stuff -->
</body>
</html>
Note the duplicated xmlns:xbl="http://www.w3.org/ns/xbl"
on the body tag.
Googling I haven't found anything about this issue, does anyone know what would cause this and what I can to to fix it?
I have noticed that if I define the xbl prefix on the <xhtml:html>
element instead of each <xbl:xbl>
element this doesn't seem to be a problem and the resulting XHTML out of Orbeon only has this prefix defined once on the <xhtml:html>
element.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Orbeon 使用 XSLT 将 XForms 文档转换为 XHTML。 XSLT 规范 说:
这意味着源文档中的两个命名空间声明必须按照规范进行复制,无论它们在结果文档中的相关性如何。
一个不相关的问题中也讨论了您偶然发现的在根节点上定义命名空间的解决方案。
在 XSLT 2.0 中,您可以将属性
copy-namespaces="no"
添加到xsl:copy
或xsl:copy-of
元素。Orbeon uses XSLT to translate the XForms document to XHTML. The XSLT spec says:
This means that the two namespace declarations in the source document had to be copied as per the specification, regardless of their relevance in the resulting document.
The solution you chanced upon of defining the namespace on the root node was also discussed in an unrelated question.
In XSLT 2.0, you can add the attribute
copy-namespaces="no"
to thexsl:copy
orxsl:copy-of
element.