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

时间:2017-02-03 15:03:17

标签: xml xsd xsd-validation xml-validation

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

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

<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 个答案:

答案 0 :(得分:2)

  1. 是的,xsd:sequence元素可以嵌套在XSD中。
  2. 是的,您显示的XSD中的K_15K_16是可选的 由于父minOccurs="0"上的xsd:sequence
  3. 另一个有用的子序列模式是当maxOccurs大于1时,表示元素的子序列可能重复在一起。

相关问题