如果未指定元素的重数,该元素是否是必需的?

发布于 2024-12-25 12:20:47 字数 1344 浏览 3 评论 0原文

我正在编写一个库,它根据 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情仇皆在手 2025-01-01 12:20:47

是的。 minOccursmaxOccurs 的默认值为 1,因此 SOPClass 必须出现一次且仅出现一次。请参阅 XML 架构 minOccurs / maxOccurs 默认值

Yes. The default value for minOccurs and maxOccurs is 1, so SOPClass must occur once and only once. See XML Schema minOccurs / maxOccurs default values

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文