如何使用 xml 模式重新定义 xhtml body 元素?

发布于 2024-12-09 02:53:34 字数 1523 浏览 0 评论 0原文

这是我的第一个问题,已经得到解答:XML 架构 - 是否可以在整个文档中仅允许某个元素出现一次?

现在我想重新定义 xhtml 的 body 元素并为其添加唯一约束。这是我的 redefine.xsd 中的 xhtml-struct-1.xsd 内的定义,

 <xs:group
        name="xhtml.html.content">
        <xs:sequence>
            <xs:element
                name="head"
                type="xhtml.head.type"/>
            <xs:element
                name="body"
                type="xhtml.body.type"/>
        </xs:sequence>
    </xs:group>

我尝试了以下操作:

<xs:redefine schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
  <xs:group name="xhtml.html.content">
    <xs:sequence>
      <xs:element name="head" type="xhtml.head.type" />
      <xs:element name="body" type="xhtml.body.type" >
                <xs:unique name="highlander">
                     <xs:selector xpath=".//mylang:content"/>
                     <xs:field xpath="."/>
                </xs:unique>
            </xs:element>
        </xs:sequence>
    </xs:group>
</xs:redefine>

org.xml.sax.SAXParseException;系统ID: 文件:xhtml-struct-1.xsd; 行号:113;列数:35; mg-props- Correct.2:圆形 检测到组“:xhtml.html.content_fn3dktizrknc9pi”的定义。 递归地跟踪粒子的 {term} 值会导致 其 {term} 是群本身的粒子。

我尝试了许多其他变体,但总是遇到我不明白的奇怪错误。如何使用 XML 架构重新定义 xhtml body 元素?

This was my first question, which was answered already: XML Schema - Is it possible to allow a certain element only once in the whole document?

Now I want to redefine body element of xhtml and add a unique constraint to it. This is the definition inside xhtml-struct-1.xsd

 <xs:group
        name="xhtml.html.content">
        <xs:sequence>
            <xs:element
                name="head"
                type="xhtml.head.type"/>
            <xs:element
                name="body"
                type="xhtml.body.type"/>
        </xs:sequence>
    </xs:group>

in my redefine.xsd I tried this:

<xs:redefine schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
  <xs:group name="xhtml.html.content">
    <xs:sequence>
      <xs:element name="head" type="xhtml.head.type" />
      <xs:element name="body" type="xhtml.body.type" >
                <xs:unique name="highlander">
                     <xs:selector xpath=".//mylang:content"/>
                     <xs:field xpath="."/>
                </xs:unique>
            </xs:element>
        </xs:sequence>
    </xs:group>
</xs:redefine>

org.xml.sax.SAXParseException; systemId:
file:xhtml-struct-1.xsd;
lineNumber: 113; columnNumber: 35; mg-props-correct.2: Circular
definitions detected for group ':xhtml.html.content_fn3dktizrknc9pi'.
Recursively following the {term} values of the particles leads to a
particle whose {term} is the group itself.

I treid dozens of other variants but I always get strange errors which i don't understand. How can I redefine a xhtml body element with XML Schema?

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

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

发布评论

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

评论(2

天涯沦落人 2024-12-16 02:53:34

重新定义群体的工作方式有所不同。

<xs:redefine schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
  <xs:group name="xhtml.html.content">
    <xs:sequence>
      <xs:group ref="xhtml.html.content">
      ... additional elements/group to be in this sequence defined here ...
    </xs:sequence>
  </xs:group>
</xs:redefine>

看起来您想重新定义类型“xhtml.body.type”,您应该尝试这样做,而不是重新定义组“xhtml.html.content”。

也许这些片段有帮助:

http://www.datypic.com/books/defxmlschema/chapter18。 html

Redefining groups is working differently.

<xs:redefine schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd">
  <xs:group name="xhtml.html.content">
    <xs:sequence>
      <xs:group ref="xhtml.html.content">
      ... additional elements/group to be in this sequence defined here ...
    </xs:sequence>
  </xs:group>
</xs:redefine>

It looks like you want to redefine type "xhtml.body.type" and you should try to do that instead of redefining group "xhtml.html.content".

Maybe these snippets help:

http://www.datypic.com/books/defxmlschema/chapter18.html

木森分化 2024-12-16 02:53:34

Have you tried different parsers/validators?

Regarding my somewhat similar issue as posted on W3C's XMLSchema Dev Mailing List there was a private response (thus not available in archive linked before) telling me about responder's tests running different parsers with different results: libxml v20708 and MSXML v20090415 successfully validated while Xerces-J 2.11 and Saxon 9.2 both had issues with the XSD.

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