Showing posts with label xsd. Show all posts
Showing posts with label xsd. Show all posts

Tuesday, 25 April 2017

Creating Simple XSD


 Creating Simple XSD

In SOA or OSB, starting part of any communication is protocol and message, in a normal SOAP message, message has to follow a structure. In SOA this structure is defined by the XSD,


Let first consider we want to develop a structure of an employee, which is pass information like firstname,lastName, salary, dataofJoining,email and type. In jave world we can think of it as a java class having attribute mentioned.

Now in XSD this can be a type, in xsd we have two kind of types, simple which are nothing but native types and other is complex which is a combination of simple types. Hence for this employee we are defining a complex type, which has every attribute defined.





To create this lets first think all the six information will be stored in six different attributes and we can  easily identified its type. now first lets think our process will take all these inputs. 




This is where we have structure defined, simply. Now its a type defined.




Now we can defined a complex type and then can assign it to and employee. Its something creating a class and then use a variable to assign.




 But now you want to keep finance information separate and person information separate, so you want to change the model something like

 Employee --- Person
                  --  Financial Details


Here first we need to create the structure and then we need to assign it to elements as type. Its can very well understand defining variable as a different class.








Now create two different variable and then assign type, which is created earlier. 







 Its the source code of the the xsd.




In the next blog we will talk about some other complex technique of the xml structure.

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.