Can anyone say the differences and similarities among the following three? XML Schema 1: <xsd:element name="aName" type="xsd:AnyType" > XML schema 2: <xsd:element name=”aName”> <xsd:complexType mixed=”true” > <xsd:sequence> <xsd:any minOccures=”1” maxOccures=”unbounded” processContents=”skip” /> </xsd:sequence> </xsd:complexType> </xsd:element> DTD <!ELEMENT aName ANY >
Hi Jane, The question seems to be very interesting. I referred to the XML Schema Part 0 Primer at wc.org http://www.w3.org/TR/xmlschema-0 and found that all the three are equivalent. The second one has I suppose is more flexible content model in the sense that it allows HTML content also. Plese refer to http://www.w3.org/TR/xmlschema-0 for explanation on xsd:anyType and xsd:any element declarations. Thanks, Rakesh.
DTD-ANY: Elements declared with the category keyword ANY, can contain any combination of parsable data.ANY means that the element can contain zero or more child elements of any declared type, as well as character data. It is therefore a shorthand for mixed content containing all declared elements. Schema-AnyType: AnyType is the default type when the type is not specified and hence this type doesn't constrain the content of the element. Schema-Any: The <any> element enables us to extend the XML document with elements not specified by the schema. The following example is a fragment from an XML schema called "family.xsd". It shows a declaration for the "person" element. By using the <any> element we can extend (after <lastname> the content of "person" with any element: <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> <xs:any minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> Now we want to extend the "person" element with a "children" element. In this case we can do so, even if the author of the schema above never declared any "children" element!