XML模式 - 只有一个元素应该有属性设置为true [英] XML Schema - only one element should have attribute set to true

查看:111
本文介绍了XML模式 - 只有一个元素应该有属性设置为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何定义只能在一个元素被置为真的布尔属性。
下面的代码片段必须是无效的。

 <产品>
  <特色产品=YES>正式版1 LT; /产品>
  <特色产品=YES>正式版2'; /产品>
< /产品>


解决方案

您不能做到这一点与XML架构。

可以在元素上定义的属性,但不将其限制到元件的一个实例。

How can i define an boolean attribute that can be set "true" only in one element. Following snippet must be invalid.

<products>
  <product featured="yes">Prod 1</product>
  <product featured="yes">Prod 2</product>
</products>

解决方案

You can't do that with XML Schemas.

You can define attributes on an element, but not limit them to one instance of the element.

这篇关于XML模式 - 只有一个元素应该有属性设置为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆