XML Schema: root element

前端 未结 6 1219
难免孤独
难免孤独 2020-12-03 04:11

The following post asks how to indicate that an element is the root element in an XML schema:

Is it possible to define a root element in an XML Document using Schema

6条回答
  •  無奈伤痛
    2020-12-03 04:51

    Not everyone agrees with it, but the fact that XML Schema can't specify a root element is by design. The thinking is that if an is valid when it's the only thing in a document, then it is equally valid if it is contained in something else. The idea is that content should be reusable, and you shouldn't be allowed to prevent someone using valid content as part of something larger.

    (The fact that ID and IDREF are scoped to a document rather goes against this policy; but then the language was designed by a rather large committee.)

提交回复
热议问题