Attribute Attribute or Type Attribute in XSD

I saw a sample like this:

<xsd:element name="Product">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="ProductName" type="xsd:string" />
            <xsd:element name="Customer" type="xsd:CustomerType" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
<xsd:element name="CustomerType">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="FullName" type="xsd:string" />
            <xsd:element name="Age" type="xsd:string" />
            <xsd:element name="Age" type="xsd:occupation" />
       </xsd:sequence>
    </xsd:complexType>
</xsd:element>

And I wonder why in this case someone would choose typeinstead ref:

<xsd:element name="Product">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="ProductName" type="xsd:string" />
            <xsd:element ref="Customer" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>
<xsd:element name="Customer">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="FullName" type="xsd:string" />
            <xsd:element name="Age" type="xsd:string" />
            <xsd:element name="Age" type="xsd:occupation" />
       </xsd:sequence>
    </xsd:complexType>
</xsd:element>

What would be the positive side of using typeinstead ref, can someone explain to me? I know that it refcan also have a parameter minOccursand maxOccursso that you can define refhow arrays are in the deserialized code.

+5
source share
1 answer

. , , . ; : , , , . , XSD, XSD, , . " ", ... , contains only one global element (, rq/rs -, ?) .

, , "Salami Slice": , (). , , .

, , , " ". , elementFormDefault .

/maxOccurs, , . . , , ref ed local, .

+5

All Articles