与 xml Schema 强制建立 isA 关系
有没有办法在 xmlSchema 中强制执行标准 isA 关系?
所以
<complextype name="item">
#can be one of
<element type="desktop computer"/>
<element type="laptop"/>
<element type="smartphone"/>
</complextype>
整个想法是 type="desktop computer" 的元素与 type="smartphone" 的元素相比可以具有完全不同的成员
它基本上是在尝试类似于语法的东西:-
itemlist = item | item . itemlist
item = common_desc . (desktop_computer | laptop | smartphone)
desktop_computer = monitor_specs . cabinet_dimensions . blah
smartphone = carrier . 3g_enabled . blah_blah
等等...
我知道这听起来像是一个相当人为的示例,您可能会说我需要为每个 item_type 定义一个新类型...但我们假设这是一组非常有限的类型...
或者您可以从以下示例中获取示例关于 isA 的另一个问题是关于 feed 的关系 (通过 Isa 关系恢复类型 )
Is there a way to enforce the standard isA relationship in an xmlSchema?
so something like
<complextype name="item">
#can be one of
<element type="desktop computer"/>
<element type="laptop"/>
<element type="smartphone"/>
</complextype>
The whole idea being that an element of type="desktop computer" can have entirely different members compared to that of say type="smartphone"
It's basically trying for something similar to the grammar :-
itemlist = item | item . itemlist
item = common_desc . (desktop_computer | laptop | smartphone)
desktop_computer = monitor_specs . cabinet_dimensions . blah
smartphone = carrier . 3g_enabled . blah_blah
and so on...
I know that this sounds like a fairly contrived example and you may argue that I would need to define a new type for each item_type... but let's assume that this is a very limited set of types...
Or you could take the example from the other question on isA relationships about feeds (Recovering types through an Isa relationship )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以像这样使用 xs:choice :-
You can use xs:choice like this :-