I'm having some confusion on the type simpletype
, simplecontent
, complextype
and complexcontent
.
I'm almost new to xsd. Can someone help to clear the confusion that giving concrete examples.
XSD elements can be of type simpleType , complexType , or anyType . An element of type simpleType contains only text. It cannot have attributes and elements. An element of type complexType can contain text, elements, and attributes.
A complex type is essentially a type definition for elements that may contain attributes and elements. An element can be declared with a type attribute that refers to a complexType element that defines the structure, content, and attributes of that element.
I know it's a bit late but I hope this article helps someone.
In short:
<complexType>
and <simpleType>
both define types. Complex types can have element descendants and attributes while simple types can't.
Complex types can have simple or complex content. Types with <complexContent>
can contain child elements while those with <simpleContent>
can only contain characters.
What is a Complex Element?
A complex element is an XML element that contains other elements and/or attributes. There are four kinds of complex elements:
Note: Each of these elements may contain attributes as well!
Examples of Complex Elements
<product pid="1345"/>
<employee> <firstname>Deepam</firstname> <lastname>Gupta</lastname> </employee>
<food type="dessert">Chapati</food>
<description> It happened on <date lang="hindi">18.03.99</date> .... </description>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With