什么会导致 Orbeon 在 XHTML 模式下生成重复的 xmlns:xbl 前缀?

发布于 2024-11-27 23:15:42 字数 3410 浏览 1 评论 0原文

我正在开发一个嵌入 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 技术交流群。

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

发布评论

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

评论(1

流殇 2024-12-04 23:15:42

Orbeon 使用 XSLT 将 XForms 文档转换为 XHTML。 XSLT 规范 说:

创建的元素节点还将具有样式表树中元素节点上存在的命名空间节点的副本,但字符串值为 XSLT 命名空间 URI (http://www.w3.org/1999/XSL/Transform),声明为扩展的命名空间 URI名称空间(参见 [14.1 扩展元素]),或指定为排除命名空间的命名空间 URI。

这意味着源文档中的两个命名空间声明必须按照规范进行复制,无论它们在结果文档中的相关性如何。

一个不相关的问题中也讨论了您偶然发现的在根节点上定义命名空间的解决方案。

在 XSLT 2.0 中,您可以将属性 copy-namespaces="no" 添加到 xsl:copyxsl:copy-of 元素。

Orbeon uses XSLT to translate the XForms document to XHTML. The XSLT spec says:

The created element node will also have a copy of the namespace nodes that were present on the element node in the stylesheet tree with the exception of any namespace node whose string-value is the XSLT namespace URI (http://www.w3.org/1999/XSL/Transform), a namespace URI declared as an extension namespace (see [14.1 Extension Elements]), or a namespace URI designated as an excluded namespace.

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 the xsl:copy or xsl:copy-of element.

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