Friday, 13 May 2016

XSD Basics -- XML Schema.



In this blog we are trying to explain about the xsd, we are taking most common xsd. Its a quite big topic. We are now covering basic of it.


Its a very basic schema about the employees.





we are explaining schema build by a user 

1. XML Declaration and Encoding 
    It provide the xml version to any parser and its encoding. Normally encoding been taken from the platform where we are developing the project. I created this XSD over the windows hence it took windows. See more details about encoding over the link


2.  Schema used in XSD
      You can very well connect it to import statement in java where import is been done from an external class to use its methods and variable. Here in this example, import of the xsd is been done to use normal xml schema, we are using xsd for reference to all the type we are using from this schema.


3. Import of own package for reference
   This  is almost like a self reference,  Just play with it to understand more :-). If you change this to xmlns:imp then you need to change 

<xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Employee" imp:type="Employee" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType> 


Hence by this we are referring to our one type created in this schema that is imp.

4. Target Namespace : 
   This is nothing but the package of the schema, where ever we need to refer this schema we need this package name to use.


5. Element
    This is almost the class declaration, where ever we need to use variable we need to mention which type is it. Element is something like a class name. Hence where ever we need data like employees we need to refer element Employees
 

6. Type Complex Type
    Its nothing but to create a complex data structure. In my example first we created a complex structure with Employee and then use it in the Employees.


I believe it will give you some idea about the normal schema created in the SOA. we will create some more blogs to explain more in the complex schemas of SOA.  


No comments:

Post a Comment