How to ask my XSD schema to check one or the other one

30 Views Asked by At

Sorry if I make a duplicate or something but I'm not really good at English (so I don't really know what tags should I chose to find what I need) (and I don't find anything in French) and I'm looking for : how can I ask my program to check if there's an apple, or a pineapple, or both. But my XML needs to have at least one of them. I just started XML yesterday. Here's my code, can you tell me if this works or not, please ?

<xsd:element name = "fruits" minOccurs = "1" maxOccurs = "8">
<xsd:complexType>
    <xsd:choice>
        <xsd:element name = "apple" minOccurs = "1" maxOccurs = "4">
        </xsd:element>
        
        <xsd:element name = "pineapple" minOccurs = "1" maxOccurs = "unbounded"> 
        </xsd:element>
    </xsd:choice>
</xsd:complexType>

</xsd:element>

Thank you for your help !

1

There are 1 best solutions below

2
Michael Kay On

Your code basically looks correct, so I'm not sure what your problem is.