xsd validate xml optional sub-elements

prodigy

New Member
I have been trying to construct an XSD file to validate some xmlXSD Example\[code\]<xs:element name="person" type="persontype"/><xs:complexType name="persontype"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence></xs:complexType>\[/code\]XML Example\[code\]<persontype> <firstname/> <lastname/></persontype>\[/code\]How can I construct the xsd to require that the 'firstname' is mandatory, and the 'lastname' is not even necessary for the xml to be valid, and that the sequence does not have to be in order, so long as the hierarchy is respected?End Result of XMLs which could be encountered, and which I would like to be considered valid according to my final xsd.Valid Scenario 1\[code\]<persontype> <firstname/></persontype>\[/code\]Valid Scenario 2\[code\]<persontype> <lastname/> <firstname/></persontype>\[/code\]Appreciate your time with the help.
 
Top