Introduction to XSD – XML Schema Definition

Posted on by By Nikhilesh, in Business Intelligence | 0

This blog will talk about Introduction to XSD – XML Schema Definition   XML Schema Definition:- XML Schema describes the structure of an XML document, what a given XML document can contain, in the same way that a database schema describes the data that can be contained in a database (i.e. table structure, data types, constraints etc.). The XML schema defines the shape, or structure, of an XML document, along with rules for data content. The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. XML Schemas are richer and more powerful than DTDs. XSD (XML Schema Definition), a Recommendation of the World Wide Web Consortium (W3C)

  • defines elements that can appear in a document
  • defines attributes that can appear in a document
  • defines which elements are child elements
  • defines the order of child elements
  • defines the number of child elements
  • defines whether an element is empty or can include text
  • defines data types for elements and attributes
  • defines default and fixed values for elements and attributes
  • xml schema support datatype
  • XML Schemas are written in XML
  • XML Schemas support data types
  • XML Schemas support namespaces

NameSpace:-

  • XML Namespace is a mechanism to avoid name conflicts by differentiating elements or attributes within an XML document that may have identical names, but different definitions.
  • It solve the name conflict by using a prefix.

<code><h:table> <h:tr>         <h:td>IT</h:td>          <h:td>Management</td> </h:tr> </h:table> <f:table>                 <f:name>Playground</f:name>                     <f:width>100</f:width>                 <f:length>200</f:width> </f:table> </code>

namespace for the prefix must be defined. The namespace is defined by the xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix=”URI“. <root> <h:table  xmlns:h=”http://www.w3.org/tr/html4”> <h:tr>           <h:td>IT</h:td>                           <h:td>Management</h:td> </h:tr> </h:table> </root>   Advantages of XML Schemas Created Using XSD:-

  • XSD provides control over the type of data that can be assigned to elements and attributes.
  • XSD enables you to create your own data types. This feature enhances the flexibility of defining the structure of the XML document.
  • XSD enables you to specify restriction on data. For example, you can ensure that the content of an element is a positive integer value.
  • The syntax for defining an XSD is the same as the syntax used for xml documents. Therefore, it is easier to learn the syntax of an XSD.
  • XML schema content models can be used to validate mixed content.

XML schema is extensible. This enables you to reuse parts of a schema in another schema and derive custom data types from existing data types.

logo

Best Open Source Business Intelligence Software Helical Insight is Here

logo

A Business Intelligence Framework

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments