Reputation: 1275
What is the point in declaring an element as a Complex Type which has one child element only?
I was given an XSD file from which I quote the following excerpt:
<xsd:element name="From">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Address" type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="To" type="xsd:anyURI"/>
I understand that the From element (which must occur once and only once in its parent) consists of a sequence (which must occur once and only once) composed of the only element Address which must occur once and only once and is a URI.
While the To element (which must occur once and only once in its parent) is an URI.
Am I right? Am I missing something?
When it comes to insert data, the user must insert one and only one URI in the Address element of the From element, and one and only one URI directly in the To element.
Which Is the point in defining From as a Complex Type while defining To as a Simple Type?
When it comes to design User Interface to insert "To" and "From" URIs both are represented by a text box which has to be validated as a well formed URI.
When converting such XSD structure to a SQL Server database, both "To" and "From" are just a varchar field in the Table representing the parent element (not shown in my excerpt) which have to be validated as a well formed URI.
But I still think I am missing some important difference. Do I?
Upvotes: 1
Views: 714
Reputation: 111686
You're not missing anything: TMTOWTDI (there's more than one way to do it) applies to XSD (and to XML in general) and provides multiple design alternatives, including:
Address
substructure, governing
organizational or industrial conventions, etc.From
element may be expanded to include other semantically relevant elements such
as Person
.From
-Address
complex type pattern.Upvotes: 1
Reputation: 163468
Possible reasons include:
Upvotes: 1