开发者

How to redefine xhtml body element with xml schema?

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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜