How do we create the XSD schema? - XML

How do we create the XSD schema?

- While creating XML documents, it is important to structure the elements such as name of the elements and datatypes which should be understood by application. Here the need of XSD Schema is sought.

- XSD schemas are the successors of DTD. The difference is that XSD itself uses a XML syntax. XSD schemas allows to declare the structure of your XML documents. This includes the inclusion of elements,attributes,mandatory and optional elements etc.

- The XML document now should conforms the XSD schema.

Example :
<?xml version="1.0"?>
<xs:schema targetNamespace=http://myorganization.org/MySchema.xsd
          xmlns=http://myorganization.org/MySchema.xsd
               xmlns:xs="http://www.abc.org/2001/XMLSchema">
<xs:element name="Employees">
     <xs:complexType>
          <xs:choice minOccurs="1" maxOccurs="unbounded">
               <xs:element name="Employee" type="EmployeeType"/>
          </xs:choice>
     </xs:complexType>
</xs:element>
<xs:complexType name="EmployeeType">
          <xs:sequence>
                  <xs:element name="FirstName" type="xs:string" minOccurs="1" maxOccurs="1"/>
                  <xs:element name="LastName" type="xs:string" minOccurs="1" maxOccurs="1"/>
                  <xs:element name="Job" type="xs:string" minOccurs="1" maxOccurs="1"/>
                  <xs:element name="EmailAddress" type="xs:string" minOccurs="1" maxOccurs="1"/>
          </xs:sequence>
     <xs:attribute name="ID" form="unqualified" type="xs:string"/>
</xs:complexType>
</xs:schema>
What is the use of FOR XML in SQL Server? - XML
SQL Server is having a fantastic feature to retrieve data persisted in the form of XML format. The data in the XML format.......
Difference between SAX parser and DOM parser - XML
SAX is developed especially for java programs. It implements a model that is memory resident.......
What is the difference between Schema and DTD? - XML
DTD supports two types of data – CDATA and PCDATA. Schema supports numeric, Boolean and String data types and suitable for applications.......
Post your comment