如果未指定元素的重数,该元素是否是必需的?
我正在编写一个库,它根据 XSD 中定义的 XML 消息格式生成 xml 消息。然而,我对以下模式有几个问题:
ParticipantObjectIdentificationContents
对象中是否需要元素 SOPClass
?
<xs:complexType name="ParticipantObjectIdentificationContents">
<xs:sequence>
<!-- there are other elements here -->
<xs:group ref="DICOMObjectDescriptionContents"/>
<!-- there are other elements here -->
</xs:sequence>
</xs:complexType>
<xs:group name="DICOMObjectDescriptionContents">
<xs:sequence>
<!-- there are other elements here -->
<xs:element ref="SOPClass"/>
<!-- there are other elements here -->
</xs:sequence>
</xs:group>
<xs:element name="SOPClass">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Instance"/>
</xs:sequence>
<xs:attribute name="UID" type="xs:token"/>
<xs:attribute name="NumberOfInstances" use="required" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="Instance">
<xs:complexType>
<xs:attribute name="UID" use="required" type="xs:token"/>
</xs:complexType>
</xs:element>
I am writing a library that produces xml messages based on an XML message format defined in an XSD. I however have a couple of questions in regard to the following schema:
Is the element SOPClass
required in the ParticipantObjectIdentificationContents
object?
<xs:complexType name="ParticipantObjectIdentificationContents">
<xs:sequence>
<!-- there are other elements here -->
<xs:group ref="DICOMObjectDescriptionContents"/>
<!-- there are other elements here -->
</xs:sequence>
</xs:complexType>
<xs:group name="DICOMObjectDescriptionContents">
<xs:sequence>
<!-- there are other elements here -->
<xs:element ref="SOPClass"/>
<!-- there are other elements here -->
</xs:sequence>
</xs:group>
<xs:element name="SOPClass">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="Instance"/>
</xs:sequence>
<xs:attribute name="UID" type="xs:token"/>
<xs:attribute name="NumberOfInstances" use="required" type="xs:integer"/>
</xs:complexType>
</xs:element>
<xs:element name="Instance">
<xs:complexType>
<xs:attribute name="UID" use="required" type="xs:token"/>
</xs:complexType>
</xs:element>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。
minOccurs
和maxOccurs
的默认值为 1,因此SOPClass
必须出现一次且仅出现一次。请参阅 XML 架构 minOccurs / maxOccurs 默认值Yes. The default value for
minOccurs
andmaxOccurs
is 1, soSOPClass
must occur once and only once. See XML Schema minOccurs / maxOccurs default values