xsd:sequences 可以嵌套为子序列吗?

Can xsd:sequences be nested as subsequences?

我想知道在一个序列中有一个序列是否有效(我假设是这样),如果是这样,从中得到的(预期)好处是什么。

我问的原因是我目前正在尝试设置一个界面来输出特定于波兰的税务文件。对于那些感兴趣的人,here's 完整的 XSD,但是我在这里只提到 "interesting" 部分:

<xsd:complexType>
    <xsd:sequence>
        <xsd:element name="LpSprzedazy" type="tns:TNaturalnyJPK">
            <xsd:annotation>
                <xsd:documentation>Lp. wiersza ewidencji sprzedaży VAT</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <!-- lots of other elements -->
        <xsd:element name="K_14" type="tns:TKwotowy" minOccurs="0">
            <xsd:annotation>
                <xsd:documentation>Kwota netto - w tym dostawa towarów, o której mowa w art. 129 ustawy</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <xsd:sequence minOccurs="0">
            <xsd:element name="K_15" type="tns:TKwotowy">
                <xsd:annotation>
                    <xsd:documentation>Kwota netto - Dostawa towarów oraz świadczenie usług na terytorium kraju, opodatkowane stawką 5%</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="K_16" type="tns:TKwotowy">
                <xsd:annotation>
                    <xsd:documentation>Kwota podatku należnego - Dostawa towarów oraz świadczenie usług na terytorium kraju, opodatkowane stawką 5%</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        </xsd:sequence>
        <!-- two other sequences like the one for "K_15" and "K_16" above-->
        <xsd:element name="K_21" type="tns:TKwotowy" minOccurs="0">
            <xsd:annotation>
                <xsd:documentation>Kwota netto - Wewnątrzwspólnotowa dostawa towarów</xsd:documentation>
            </xsd:annotation>
        </xsd:element>
        <!-- lots of other elements -->
    </xsd:sequence>
    <xsd:attribute name="typ" use="required" fixed="G"/>
</xsd:complexType>

我的问题是:

  1. 是否允许序列中的序列(没有任何分层节点,如元素或复杂类型)?
  2. 将元素 K_15K_16 作为一个序列有什么意义。是因为可以省略两个但不能单独省略吗?
  1. 是的,xsd:sequence 个元素可以嵌套在 XSD 中。
  2. 是的,您显示的 XSD 中的 K_15K_16 是共同可选的 由于父 xsd:sequence.
  3. 上的 minOccurs="0"

另一个有用的子序列模式是当 maxOccurs 大于 1 时,表示元素的子序列可以一起重复。