XML 架构多个元素和属性
我有这样的代码:
<root>
<skill id="1">C++</skill>
<skill id="2">C#</skill>
<skill id="3">Java</skill>
<skill id="4">PHP</skill>
<skill id="5">MYSQL</skill>
<skill id="6">HTML</skill>
<skill id="7">CSS</skill>
<skill id="8">JavaScript</skill>
<skill id="9">XML</skill>
</root>
我正在尝试为此创建一个架构,但我不太确定如何声明具有相同名称及其属性的多个元素。 XML 架构:如何拥有多个相同的元素?不确定究竟发生了什么。当我设置 minOccurs 时,我需要 maxOccurs 吗?在上面的链接中,我不理解模式中的属性部分,有人可以帮助/详细说明吗?
I have this code:
<root>
<skill id="1">C++</skill>
<skill id="2">C#</skill>
<skill id="3">Java</skill>
<skill id="4">PHP</skill>
<skill id="5">MYSQL</skill>
<skill id="6">HTML</skill>
<skill id="7">CSS</skill>
<skill id="8">JavaScript</skill>
<skill id="9">XML</skill>
</root>
I'm trying to create a schema to this and I'm not quite sure how to declare multiple elements with same name and it's attributes. XML Schema: how to have multiple identical elements? but was unsure exactly what was going on. Do I need maxOccurs when I put a minOccurs? And in the link above I don't understand the attribute part in the schema could somebody help / elaborate please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面声明了
root
元素,该元素只能出现一次且必须指定,以及一系列具有id
属性的skill
元素xs:IDREF
。xs:attribute
< /a> 声明元素的属性。name
属性指定属性名称。type
属性指定数据类型。不,您不需要
maxOccurs
。如果您未指定,则存在隐式maxOccurs="1"
。The following declares the
root
element, which can only occur once and must be specified, and a sequence ofskill
elements with anid
attribute of typexs:IDREF
.xs:attribute
declares an attribute for the element. Thename
attribute specifies the attribute name. Thetype
attribute specifies the data type.No, you don't need to have
maxOccurs
. There is an implicitmaxOccurs="1"
if you don't specify it.