XML and XML Schema Definition in easy steps | Bharath Thippireddy | Skillshare

XML and XML Schema Definition in easy steps

Bharath Thippireddy, You are the creator of your destiny

XML and XML Schema Definition in easy steps

Bharath Thippireddy, You are the creator of your destiny

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
54 Lessons (1h 46m)
    • 1. 1 Install Eclipse IDE

    • 2. 2 Launch Eclipse

    • 3. 3 Course Introduction

    • 4. 4 Introduction

    • 5. 5 What is XML

    • 6. 6 Why XML

    • 7. 7 When to use XML

    • 8. 8 XML Processor

    • 9. 9 Hello XML

    • 10. 10 XML Hands On Introduction

    • 11. 11 Drivers License Usecase

    • 12. 12 XML Declaration

    • 13. 13 Encoding Attribute

    • 14. 14 Standalone Attribute

    • 15. 15 Elements

    • 16. 16 Create Child Elements

    • 17. 17 Attributes

    • 18. 18 Empty Elements

    • 19. 19 Comments

    • 20. 20 Character Entities

    • 21. 21 CDATA Blocks

    • 22. 22 Nested Elements

    • 23. 23 Welformedness Recap

    • 24. 24 XML Schema Introduction

    • 25. 25 What is XML Schema

    • 26. 26 Why XML Schema

    • 27. 27 XML Schema Types

    • 28. 28 XML Schema Hands On Introduction

    • 29. 29 Patient Management Usecase

    • 30. 30 XML Schema Data Types

    • 31. 31 Assigning types to fields

    • 32. 32 Namespace Basics

    • 33. 33 Schema Creation

    • 34. 34 Define Elements

    • 35. 35 Validating XML

    • 36. 36 Simple Types Introduction

    • 37. 37 Restricting the length

    • 38. 38 Using Enumerations

    • 39. 39 Creating Complex Types Introduction

    • 40. 40 More Requirements

    • 41. 41 Making a choice

    • 42. 42 XSD ALL

    • 43. 43 Complex Types in other complex types

    • 44. 44 Controlling the number of element occurances

    • 45. 45 Validate XML

    • 46. 46 ElementFormDefault

    • 47. 47 Attributes Introduction

    • 48. 48 Adding Attributes

    • 49. 49 Required Attributes

    • 50. 50 Assigning SimpleTypes to Attributes Values

    • 51. 51 Include and Import Introduction

    • 52. 52 Namespace Recap

    • 53. 53 Including Other Schemas

    • 54. 54 Importing From Other Schemas

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

This course is primarily targeted at students needing to understand the syntax and concepts behind XML and XML Schemas. This course is also for anyone who want to learn how to use XML Schemas to define the structure of XML languages and how to validate XML documents against XML schemas.

XML has become a widely used standard for storing and exchanging information on the internet. Knowing how to work with XML has become a core skill that every developer needs to have. In this course, we'll start off by learning about what XML is and does, and some of its advantages.

At the end of this course, students will be able to write well-formed XML documents, validate and enforce business rules using XML schemas

Learn and master the XML and XML Schema technologies in this comprehensive course.

  • Understand what,why and when to use XML

  • Work on a XML Use-case and master the various concepts and syntax of XML Components.

  • Demystify the topics of XML Schema Definition

  • Work on a Use-case and create a XML Schema File

  • Learn using the inbuilt,simple and schema types

  • Validate the XML documents using the schema

  • All in easy steps

Mastering XML and XML Schema Definition for Professionals:

XML was designed to store and transport data.A Schema validates a XML document and acts as a contract between two parties using XML.

Any developer or analyst at any level can access the key lessons and concepts in this course and learn to write xml and xml schema documents.

Contents and Overview:

In over 2 hours of lectures this course covers necessary XML and its validation using XML Schema.

This course covers the importance of  XML , the Well-Formedness rules ,how validation works and how to use XML Schema Definition to validate a XML.

Up on completion you will be able to create XML Documents , create and use XML Schema files and also import and include schemas in other schemas.

Meet Your Teacher

Teacher Profile Image

Bharath Thippireddy

You are the creator of your destiny


Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.



1. 1 Install Eclipse IDE: in this lecture, it will set up the simple software that is required for this course. By the end off it, it will have the eclipse I d installed on your machine eclipses a popular open source I d usually used for Java and Java E development, but it has very good support. For example, example, schemer definition. So I will start by downloading this file from the contents off this lecture, which is called development tools set up dot txt. The first step is to install job abortion because eclipse idee is our best and it needs java. If you already have a job I installed on your machine, then you can skip this first step. If not copy this. U R l and roll See, Go to the Web browser based it or the oracles gvk down Lord Page even see the various Russians off Jerry care for Windows, Lennox Mac etcetera. So if you are on windows, you can use these here The X files no Lord them double click on them and they will be able to do follow the prompts and easily installed java. Similarly, if you're on, Mac will use this DMG file and for other operating systems. The other versions. He should accept the license agreement and then click on the link to download it. Once you have the Jerry Kane start, installing Eclipse is very easy. Eclipse comes as a ZIP file. Copy it again. If you have some version of Eclipse already installed, that's good enough. I have the latest, or at least I have the Mars abortion pays. The You are a Linda Web browser, which will take you to the Eclipse. Don't Lord speech. There are different versions off Eclipse again. The latest is neon packages. You can don't know that what I have is Mars. And here, as you can see, there are different versions available for different operating systems. For Mac, it is a DMG file for Windows. It is simple zip file. Unzip the contents off Eclipse toe, see Dr B or D drive and create a shortcut on every desktop which will look like this. In the next lecture, I will show you how to launch the clips I D and work with it at a minimum. If you have any shoes by launching the eclipse, I d. You can follow this troubleshooting instructions here setting the pop environment variable on windows setting Javon Underscore Home, etcetera. In most cases, these are not required. If you install Jerry K properly and if you installed, just unzip the contents off eclipse. We shouldn't see any issues, But in case if you see issues, do follow the troubleshooting instructions, and you can also post me the questions through a message or a discussion. 2. 2 Launch Eclipse: in this lecture, I will show you how to launch the eclipse. I d. Once you have their clips in Starliner machine, you will see an icon like this under the Eclipse Installation folder, you can create a shortcut for it and our click on that icon which will lost their clips I d . As soon as the eclipse opens, it'll prompt you to select workspace. You can browse and select the folder on your machine where you want Oliver Eclipse projects to be saved in eclipse. Everything we work on is a project. So when we create XML files, XML schemers, we first start by creating a project. And then we put all our files into those projects. This is a location very want eclipse to store all those projects, it could be your C drive. You drive. It doesn't matter. Once you select that folder, click OK, That felt complete the launch off eclipse and will be taken to the eclipse dashboard like this in sections later on, it will be creating multiple projects both, for example, as the last XML schema 3. 3 Course Introduction: Hello there. Welcome to the X Amel on XML scheme our definition in easy steps. In this video, I will give you an order. You walk the course so that you can use it effectively. This course is organized into sections and eat section has one or more lectures at the end off its section. There is a quiz for you to do a self assessment on what you have learned from that section . The questions in these quizzes are what you usually face in job interviews and exempts. Consider 70% as a good score in these quizzes, there is a easy software set up section right at the beginning. Off the course, I recommend you set up all their quite pools before you start the course. As you cruise through the course, you might have some questions. Feel free to ask those questions by either sending me a message on your enemy. Our discussion before posting your questions as a discussion, I recommend you check if the questions are already posted by someone yells earlier on there already answered for you. I also recommend you participate in others discussions and reply to their questions as it is a great way off Learning the course has enough material for you to master Example as well as XML. Scheme our definition, but you have to practice to make the best out off it. Always feel free to get in touch with me and ask questions. Now I suggest you get started and learn example. XML scheme our definition in easy steps. 4. 4 Introduction: from this section you will master the concepts of maximal That is what exam, Elise. Why we need it. Or ways it's so popular. Then they use it on the country with the section by creating excellent document using the eclipse ivy. 5. 5 What is XML: from this lecture, it will learn. What example is XML stands for extensible markup language, as the name itself say's. We can create our own markup required for our business purposes using excimer. If you are familiar with his team, L then you know that his team provides pre defined set off elements that are special meaning to the data that they wrap. For example, John here in Bold, surrounded by the B tags his team attacks will be interpreted by the Web browsers like Internet Explorer, Chrome and Firefox in Bold. Each one will display this text here. Welcome to the world of maximal in a slightly bigger formed and in bold. So his demon adds a special meaning to the data. Or it acts presentation value to the data traps, and it has a pretty find set off elements. Whereas example doesn't have any pre defined set off elements, it allows us to create our own XML. Using example, we can define our own markup. For example, if we are working on e commerce application, we can create a order ml which will have the already line items shipping address on all that we need for the order data. Similarly, if we're working on a new SPORTAL, then we can create a news ML which can carry the headlines, politics and prevention, political information, our political news as well as sports data Applications can then use this maximal to save it to manipulate and display to the end, user or even toe exchange this information with other applications. That is the power off XML to summarize XML, which stands for Extensible markup language. Unlike his team will, it doesn't have any pretty find set off elements it ellos as to create our own markup language or markup elements so that our applications can use the data however they want and they can do whatever they want to do with that data very easily. 6. 6 Why XML: Why XML our water? The advantages off XML the number one advantage, which you already know from the previous lecture, is that we can create our own custom markup using XML. For example, if we're working on e commerce application, we can create a harder maximal which has the hard already shipping in for all the product information, etcetera. A second and the major advantage of example is it carries both the data on the meta data. For example, let's say we are all together working for Amazon on their Amazon Web application, which allows the customers to place an order and then Amazon shipping application, which will ship the order to the customer when it is ready. Now, as soon as the customer place an order or when the product is ready for shipping on Amazon , Web application sends the data to the Amazon shipping application as XML, the Amazon shipping application. Looking at this, XML, which has bought the data which is 1234 already, and the address for shipping info on the meta data, which is the Order i d. The shipping in four knows what to do with this data will immediately know that This is for order 123 and the shipping info is where it should ship the order. Finally, example follows certain Val former NUS rules. So we have to make sure our the applications that are producing XML how to make sure that they are sending in a clean XML. Otherwise, applications which are crossing the XML can rejected. Similarly, we have validation rules which are very powerful. We can create schema files, for example, and then these applications which are exchanging data. For example, when the Amazon replication sense Torretta Amazon shipping application can validated that data against a schema which they have agreed to even before these applications were developed. To summarize the main advantages off using XML are it allows us to create custom markup. It has bought the data on the matter data, which makes it easy for applications to I consumed the data and make some sense out off it . Finally, it follows certain Val former NUS rules and also it allows us to do data validation before we do anything with that data 7. 7 When to use XML: When are where to use XML or Berries? XML Mostly used. There are three places in which maximal is mostly used or should be used for data exchange for configuration finds. To save data on to manipulate and present data for data exchange, for example, we have application one on application to and these two applications how some data in common or they want to exchange some data. Example is the way to go because example has both data as well as meta data, and it can be validated as well. The technologies that we can use could be so pep services, restaurant services, simple RPC or remote calls. It doesn't matter, but all these internally use XML toe Exchange the data. Secondly, as a con figuration file. If you're a software developer or a tester, you already know several configuration files like the web dot XML in Java, space for your Web applications, sober dot XML for your application servers, the bomb dot XML and build or maximal forever build files. XML can be easily used as con figuration files because we can again provided the configuration information as data. And then the meta data tells what the configuration information is for. Finally, we can use XML to save the data manipulated and present it back to the user. I once worked on a new sportal application where in the data was saved into a repository as example, and then at some point later this portal reproduce that excitement manipulated. And since the XML has hitched Deimel, it uses style sheets, converts taxable into his Deimel and sense it back to the plane. So these are the three big areas in which XML can be used, starting from data exchange to configuration files to saving the data are manipulating it and presenting it to the client. 8. 8 XML Processor: Once you start working on example and XML schemers hands on, you will hear the term maximal processor. XML processor is any software application or library that can read XML document structure and check for its well, former NUS and validation all XML editors like Eclipse Example, Spy and even Web browsers like Internet Explorer and Chrome have a XML processor built inside them on a direct user. For example, Processes, especially when it comes to programming languages, is a XML parcel. Again, it is a software library that can really XML and make it easy for programming languages like Java, Darknet fight on or any other programming language. The XML part. Sir, we'll make it easy for these languages. Or it will read the XML structure on represented in a format easy for these programming languages to make use off that XML The summer days. Once you cruise through the example, hands on XML Schema Lectures will be hearing a term called example processor. It is nothing but A software that can read XML file structure on represent our check for its well formulas and validation. And when you're working with programming, languages like Java are dotnet, it will listen to a term called at symbol Parcel. It is nothing but XML process that can really XML check for its well, former NUS validation and then easily the president that exam Alina former that these languages can understand instead off blame fixed. 9. 9 Hello XML: No that you know what XML is, why we need it and where to use it. It's time to learn how to create XML. To do that launched the eclipse i d by clicking on a clip shortcut. Once you are in eclipse, go to the file menu Say new project Everything in eclipse is a project, so you have to save your files into a project under the general section. Here, select the project. Click next, Give your project a name. Let's call it Hello XML and click Finish. We have our project ready to create example Document Right Click on the project Go to new Goto Other at the end here in the Wizards search Pipe XML and they will find the XML Bizerte under it, we have to wizards One is like someone filed. The other is XML schema Select XML file click next. So, like the project under which you want the file to go Your example Filename. Let's call it hello dot XML extension off XML file is always dot xml click finish and we have our first example Document eclipse creates this first example declaration element He will learn the details off each and everything in this element in the next section. For now, let's create our greeting example, creating as soon as you close the element Eclipse automatically genders The end element for it it will learn about the root element. Will learn about the Val former ness rules and all that in the next section in here. Hello, Excitement start simple to come up with example document using their clips. I d. Here we have one route element called greeting inside, which we have another element called Hollow and the data is example And the meta data is Hello. The quickly summarize to create an example document. We go to the file menu saying new first we create a project, give it a name then we'll right click on the project Se knew Go to other type in XML in the search here Select maximal file, say next and give it a name. Then come back here. Start typing or xml Darkman with the elements and data in it 10. 10 XML Hands On Introduction: from this example Hands on section, you will learn how to create a XML document from scratch. By the end of the section, you will have a driver s license examine created using very a sex. Some of elements introduce entities Commons, except 11. 11 Drivers License Usecase: in this lecture, I will introduce you to the driver's license, use case or requirement we have. Most of the countries have a centralized driver's license issuing systems like the embassies in the U. S. A. Party or the road transport officer in India, where in the sure driver's license for its citizens, for various types off vehicles like cars by express X etcetera and these software applications which they use sale this information to their own database on file system. Now we have a requirement wearing we're building an application where banks are other. Third party applications like insurance companies can access this driver's license information from this centralized system. To do that, they want to exchange this information as example. Our job is to come up with this XML. This XML can also be used by other applications within the the MPs are the articles are within the government organizations. For example, the license information every time you get a speeding ticket are every time you jump a signal. In countries like USA, your license is essay in some point, so there can be an application within the the M V office, which can pull your license information assigning some points and save it to a different database. So this XML can be used in various ways. But our goal is to simply come off better. Example. Document. So here is the elements that this XML will have are the fields that the sentiment should have. We can call this the driver's license ml markup language number, the license number. The first name off the river, the last name of the river, the data. But of course, the vehicle, whether it's a car, a truck or a bike, the date of issue off the license, a photo start, the photo itself, but the location off the photo very D stored on the central database server on, then expiry date off the license, so we'll be building example document using all these fields in the next few lectures. 12. 12 XML Declaration: Every XML document starts with the declaration, also called a prologue statement. In this lecture, it will learn the syntax off XML declaration by starting working on the driver's license use case. To do that, launch the Eclipse i d. Go to the file menu that's creating new Project New Project not a Java project, but a simple project. Go under the general section to his project. Click on Next. View Your project in name. Let's call it Driver's License XML and leave everything, as is the default options. Click on Finish. We have our project pretty right. Click on the Project SE knew. Go to other type in X Emmel under the XML templates. Choose the XML file. Click on Next Your file. A name? Let's call it drivers License l Capital. You can name it. Whatever you want. Click on finish. As you can see by default, the Eclipse i d creates the maximal declaration, the very first line in XML document. For us, it starts with the less than symbol question mark on. It ends with the question mark and greater than symbol. These symbols tell the XML parcel or the processor that this is a processing instruction and it is not the actual XML document or the elements and attributes in the XML document. We can have other types of crossing instructions like style shoots, etcetera. This XML tells maximal parcel that this element is from the maximal specification are not style sheet the version using the Russian attribute on this element, we can specify what washing off XML were using. The current version of example is 1.0, I will explain a border and according on also a standalone attribute in the next lecture. To summarize the very first line in every XML document is a XML declaration. Ideas like Eclipse will create that line for you by default. The syntax What it is less than symbol question mark, and it ends with a question mark and greater than symbol. We have various attributes on it, like version and cording, and stand alone will learn about and according and stand alone in the next lecture 13. 13 Encoding Attribute: in this lecture it will learn how to use the and according attribute on the XML declaration or the prologue and according is used to specify a character cept that we are going toe used to represent the text within our XML document by default. It is beauty of eight. So if you take this and according out religious attribute entirely by default maximal part surrealism beauty off eight we can also use other character sets like beauty of 16 which can represent most of the characters from most of the languages on this planet. We can also use other characters. It's like I s whoa shift J s You use IGP and so on to summarize by before then according for the characters in our XML issue tee off eight but you can use other character sets as well 14. 14 Standalone Attribute: In this lecture, he will learn about one more important attribute on the XML Declaration, which is the standalone attributes. This standalone attribute tells the XML part, sir, whether this example document exists on its own or whether it can use documents from outside like XML schema. So this stand alone can have a value off. Yes, are no. Yes, tells the example, Prosser, that there are no external documents required for parsing this document and this XML document exists on its own. The default value is no, which tells like some a process that this XML document can use. Other documents like example scheme are XML style sheets and so on. 15. 15 Elements: elements are the heart off every examined document XML document is cos off one or more elements nested inside each other. It should always start with root element. So let's create the truth element for our driver's license. Use case by going to eclipse, double click on this driver's license. Not example. Tap so that it will maximize. And in here, let's give our route element and name. That's call it drivers license. As soon as you close this element, Eclipse automatically creates an end tag or end element for the start element to every element has a start Back under intact starts with the less than symbol and ends with a greater than symbol. And the intact starts with the less than symbol followed way forward stash and then ends with a greater than symbol within which we have the elements name. Within this element, we can How multiple other elements which will be creating in the next lecture are we can have textual data. There are certain naming conventions that we need to follow. When we create elements they are start an intact, often element must be identical, meaning we have driver's license here. You can't just say drivers here. If you say that it keeps immediately points to us that there is a problem with this, the element type driver's license must be terminated by matching n tag. Driver's license Control Z and the other is gone so they're clipped. Sparser is running behind the scenes, and it isn't immediately complaining about the well former NUS problem. The second room names are case sensitive. So if use upper case for the start tag, you should use the same exact case for the intact as well. So this de, for example, on the intact. If I change this d from capital to small, save it immediately. A clip sparser points out the error message. It says the element type driver's license again must be terminated with it. Corresponding driver's license to the Parson's XML partners are case sensitive. The rule, an element name, can contain any alphanumeric characters. City straightforward. We have already used only the Alfa characters. That is alpha bits. We can also have numbers in here if you want. The end element should also be the same. The last and final rule, if at all. There are any special characters that are allowed. They are the hyphen underscore and period the dart symbol so we can take over this 123 and use a hyphen dot underscore. You cannot use any other special characters. Let's try using yeah, start as you can see the color changes immediately. If you want to see the explicit error message right, click on the file and click on the validate button. The valuation completed. One letter was discovered. One resource was validated in under a second will see the error message. Under the problem. Step Element type drivers must be followed by either a tribute specifications greater than our slash Greater than so the parts are is confused. It thinks the element ends right here. So don't use special characters other than high funds underscores and dots. So in this lecture you have learned that we can have one and only one route element. We have created the driver's license root element for our use case. This route element can help. One are more change elements and also textual information. The naming conventions. There are four different naming conventions, which you should always remember to get rid of. This error can right click, save, validate again hit. Okay, No more errors 16. 16 Create Child Elements: in this lecture, we will fill in the driver's license exam away with all the fields from our use case. That is the license number. The first name last name data, but vehicle type date off issue on expiry date will cover the photo in the next lecture. When you learn about attributes, let's start by creating the chilled elements for this driver's license less than symbol. The first field is number. As soon as you close it, Eclipse will generate the end element for it. So within here we can have any textual information. Let's say 12345 That's the first child element off driver's license. Let's create another child elements. So the sub elements off another element are called chilled elements, and the element which encloses them is called the parent element. The next is first name. You can follow any naming convention. I'm falling the camel case here. Let's a parrot and then that last name period E. Go back to the use case data, birth vehicle type and date off issue. Date off, but 18th off me. 1981. No secret there. Vehicle pipe. Let's keep it simple. Let's call it a car. Usually they have a core for this. Like see, be four bikes, etcetera. But let's keep it straightforward. It a birth vehicle type. Then we have the date off issue and expiry date, so date off issue. It's a 11th off June 2012 finally date of expiry or expiry date. That's 11th off. June 2000 15. That's it. We are done to remove these lines here. The spaces. The partner doesn't care about the spaces to former their document. You can hit control Shift F that has moved all these elements to the right so that it is easy for us to read. This document will immediately know that these are the jail elements off the driver's license. So it's that simple to create an XML document with one root element. Always, it can have any number off chilled elements which can carry textual information off different types, numbers, characters, dates and so on. 17. 17 Attributes: elements in XML, Darkman might feel lonely and get bored. If they don't have any company, that is, their attributes come into picture. It will learn about attributes by using the photo field from our requirement. The photo has to include the location off the drivers photographed on the server, so to do that will add a photo element p Capital and instead off having a textual value off the location. We can simply use a location attribute, and this location can be some server name appeared US Office Server slash the filing attributes. Unlike elements, they don't carry the actual data, but they qualify their data on Artem Special meaning to the elements. Another example could be We can have a unique i. D. Or we can have a status on the driver's license, which tells whether it's a active or whether it's canceled or whether it was suspended for some beautiful reasons, like you have driven 100 150 owner 15 speedily made road. So this status attribute here qualifies this entire driver's license, but it doesn't directly carry any data that belongs to the driver's license itself. To summarize attributes are name value pairs the names always follow the same naming conventions as the elements, and the value should always be inside. Double courts are single courts. 18. 18 Empty Elements: elements that do not enclose any child. Elements are text data are called empty elements in our Driver's license XML. The element photo does not include any textual data. Are chilled elements off its own? It's empty. It simply has a tribute on it called Location, which tells about the location off the photograph. That is why they are useful, the add value only through their attributes. But these elements should always be closed, either by using an end element are we can use the shorthand notation where you can type in the forward slash right here on the start element on, we can delete the and element completely. 19. 19 Comments: XML comments help us as well as other don't Uppers are readers who are reading our excellent document using XML comments. We can state the purpose off the entire document as well as the elements and attributes in it. The syntax for comments is less than symbol, not hyphen hyphen. Eclipse immediately gives us that closing off the XML comments, which is hyphen, hyphen credit than symbol of it. In this, you can type whatever you want. This XML document holds that license information. We can also have comments in between elements. For example, the expiry date. It varies in the countries like us. The expiry date off the license for the citizens. It is four years, and for visa holders, it is that visa expiry date, so it might change from country to country just to make it more obvious. Here we can addict comment like this if you're a developer, if you have used example for con figuration, another way to use comments is to temporarily comment out a certain element to do that instead off typing in the comments, we use this less than symbol. For example, here I want to comment on the date of birth I can say less than symbol, not hyphen hyphen. Remove this and element that was generated by Eclipse. Go here to the end to the greater than similar day and and type in hyphen hyphen just before it. And this entire element is now commented out. So we use this as developers temporarily comment out certain con figuration in XML files to summarize comments, statements within maximal that are skipped by the XML part. Sir, we use it to provide more information about the document itself are about the elements and attributes in a document which will be very helpful to us or any other people who are reading our XML documents. 20. 20 Character Entities: in this lecture, it will learn about pretty find example entities. Before we do that, let's fix one thing without example. Darkman looks like I have accidentally deleted the vehicle type, so let's add it back after the data. But vehicle type, if you already have it, need not at it. The value is car No. We cannot directly use this less than symbol, the greater than symbol the double courts. Single courts are even 1% symbol inside the text off our XML document. So let's use the example pretty fine entity types. There are five different entity types that the example specification provides, so we can use instead off the left angler bracket or the less than symbol we can use it at ampersand. Lt. All these characters are courts. Start with it and person symbol end with semi colon in between the house. Some characters, which the example parcel will ignore as soon as it sees this ampersand symbol. It knows that it is a special character or a court from the XML specification, and it will ignore them, try to radically used the less than symbol Let's put it at less than symbol. Inside my last name, right Click do a validate and immediately you get an error. Because the example Parsa is confused. It is looking for a greater than symbol or a slash greater than, but it found the less than symbol instead. So instead, off this less than symbol, I can use it and per signed lt semi colon on person. Lt. Same equal and right click Validate. I don't have the error anymore. So if we ever have a requirement very in your data needs to contain any off these symbols, you have to use the special courts and then you can retrieve the data as is and save them to your database for greater than it is and percent GT semi colon for 1%. It is and percent a MP semi colon for court, single core trees and percent court semi colon for double court. It is n percent AP boys Semi colon. You can try experimenting with all the different types, of course, but the main thing to remember is you can are directly use these characters. Since they are used by XML and the parts that will be confused. It will have to use this pre defined character entities that are provided by the maximal specification 21. 21 CDATA Blocks: In this lecture, you will learn about the sea data blocks using the C data blocks. We can include any text, any characters inside our XML document the syntax for the sea Data block starts with a less than symbol, followed by not square bracket and then text see data followed by another square bracket. And it ends with blue square brackets and greater than symbol within this square bracket here and the square bracket here we can type in any text and the example part sir will ignore it. The Syria tha blocks are usually usedto give examples. We can include an XML document. Here are we can include a piece off our XML document like the date off issue anarchists. If you want to showcase the format off the date that should be used and how it should be used, weekend give examples like this we can include it and the parcel will not complain about the lessons Involve a greater than symbol R E for use any characters. It will simply ignore the entire see data block. So if I right click on this now on, do it Validate. There are no errors are warnings. That's the beauty hope using Syria blocks. We can have any number off Syria. Tha blocks within our document anywhere but we cannot nest one seeded a block inside and other Syria tha block. So to summarize, we can you see that a lot to include any text in or examine documents instead of using character entities one at the time they both how their own uses. But you should use one off those as required for your application. Usually, Syria blocks are usedto you some examples off your exam allotment or how to use the various elements in your XML document. 22. 22 Nested Elements: before we wrap up the example section by discussing well, former Ness rules in the next lecture will take one last requirement. That is, we will add address to our license, and the address should have a street city, state, country and that zip court. Using this, we will demonstrate how XML can have mastered elements inside Nestor elements. Multiple levels off Mr Dennis, go to the Eclipse i d. After the photo will add a new element called Address on this address. We'll have now have changed elements. Starting with Street City State is another element country and finally zip cord. Now we have multiple levels off nesting here. The driver's license, the root element has address as a stale element on Brasington has multiple elements inside it, which are the tail elements off address. So address becomes the parent off street city, etcetera, and for address, the parent is driver's license. So street, city, state and all become the grandchildren off driver's license, So example, is a hierarchical document. We can have any number off hierarchies or any levels off nested nous. Let's fill these with values Street. Let's call it Stevens Drive City. Let's how one of my favorite cities in the USA King of Brescia State, Pennsylvania. Be a Country USA report 194 or six It's that simple toe. Add any levels off Nestor elements in the next session will use all these elements on Park about our recap all the malformed nous rules that we have been following so far while creating XML. 23. 23 Welformedness Recap: in this lecture, I will summarize all the Val for Melissa rules that every example document should follow on . We have been following since we have started working on the driver's license XML. The first rule is every example document, but must have a root element In our case. The root element is driver's license. There is only one and only one route element. All the other elements become Children off this wrote element. We have followed that. XML elements must have a closing pack, so every element that we start should have a closing tag. We can use a shorthand notation like we have used in case off photo. If it is an empty element, we can close it right on the start back, instead of having it separate intact, were allowed to have a separate and tag as well. But this is a shorthand notation. Their example. Elements must be properly nested. So if we have started this element address inside off driver's license, we should also close the ending element off address before the driver's license ends. So I can't how this closing element. I cut it and paste it after driver's license. Immediately we see it error. It says address must be terminated so we should nested the elements properly. That is another well former NUS room example. Tags are case Since do you have seen this? If I started tag with street, I should also ended with all lawyer case I can use apart. If I use upper case here immediately, there will be an error example Attribute Values must be courted. You are already using this as well in the photo. If I take these courts out for the value, it is not a valid except mollify. Validate this Now the valuation fails. One resource while was validated but there were others discovered. And if you point it on, their one court is expected for the attribute location. So that's the final rule off well form illness. 24. 24 XML Schema Introduction: using examples came off. I am applications can validate back someone. Let the exchange on this section. It will learn what this came up by this why we needed on how to create one. We also learned different banks that are available and we create a XML skim off. 25. 25 What is XML Schema: from this lecture it will learn water Example scheme. Our definition is XML schema defines the grammar are a blueprint for example Document that is we can use the XML schema to mention what elements can be there in XML What attributes can be there? What name? Spaces that XML can use The order in which the elements should occur the number of occurrences off each element And also we can restrict the data inside the XML document only to Sartain values All that can be done using the maximal schema definition if examined document follows the schema file if it has xml scheme are defined and if it follows that schema file it is called a valid example document XML scheme Our definition is also xml file but Dark x s the extension instead Off dark XML, it will have a dark xsd with stands for example schema definition all the elements that we can use inside a schema fine are provided by W three c the World Wide Web consortium. They defined the specification off the XML schema, for example, If we have an order not XML, we can have ordered or xsd which say's what elements can be present and water tributes can be present and in which order in the order dot xml to summarize Hey, schema file Using his chemo file, we can define the grammar for our XML documents. Schema file is also an XML file, and the elements that can be used in the schema file are provided by the World Wide Web Consortium. If XML document has a scheme of ill defined and if it follows that schema file is called a Valley example document. 26. 26 Why XML Schema: Why do we need XML schema file and where do we use it? XML Schema file is a contract between two x Immel users. It is if application one and application to are exchanging XML messages for some data. We don't a contract to define for what elements and attributes should be there. In this XML document application, one can send in any daytime XML which application to doesn't even care or doesn't even understand. Similarly application to can also do something similar by sending wrong data are additional data which application one doesn't care? That is where example schemer definition comes into picture and these two applications, right when they are being developed, can agree on a contract by defining all the elements and attributes inside the maximal scheme. Our definition file for this XML. Similarly, let's say we are. We have bought a new employee management software for our enter place and now this employing managements are fair from 1/3 party has to access our employee database and the third Party software has asked us to use the XML configuration file so that we tell this software where our databases and how to access it inside that XML configuration file. This third parties offer will validate our example that we come up it against the schema file and they provide us This came out fine so that by looking at this schema file, we will know what elements we can include inside that configuration file. So wherever and whenever you use example to make sure that the Axe Families Valley it is carrying value data, we need a contract. And that is where example schemer definition comes into picture on. We can specify everything that XML can how, inside a maximal schema definition. 27. 27 XML Schema Types: Maximus scheme. Our definition specification gives us three different types that we can use in the XML schema. To mention what type off data or examined documents carry, they are in built types. These are defined by the W three C. They are integers, decimals, spring date, date time and there are several other pipes which I will show you later on. You can use all these types on. We build our skimmer document and mention that our element should be one off. These types are attributes should be one off these types. We can then even extend these inbuilt types by creating our own simple types if we want to restrict. For example, if you want to restrict a stringer to 15 characters, we can use the inbuilt string type as the base and then we can use a restriction from the XML schema on. We can create a simple type and then we can apply that simple type and we define the elements inside our schema file like this. You will see all this in action even do this hands on in the next few lectures. So far, we have seen their inbuilt types and then to create simple types by extending those inbuilt types. Finally, we also have complex types. Complex types are elements which can have other elements inside them. We can create complex types either by using the inbuilt types are simple types are other complex types can use the combination off these three. So in this lecture you have learned the three different types which we using over scheme or document the inbuilt types, which are defined by the W three C and then the simple types which we create. These are the custom data types. The syntax for creating a simple type is again provided by the blue three C and finally, the complex types from the object oriented background. Then complex types are like creating your classes by using the available in built types. 28. 28 XML Schema Hands On Introduction: It's time to work on a hands on use case and fear, and some of us came out fired from scratch. By the end of the section, you know, created a schema file using the inbuilt dinner types that are available from the W three c example scheme on specifications. 29. 29 Patient Management Usecase: In this lecture, I will introduce you to the hospital management or patient management use case for which will be creating a XML schema. Let's say you and me are working as a team on integrating two applications, namely the Patient Financials Application, which deals with the patient. Personal information is insurance information and all that when he's checked into a hospital and then the patient clinical application, which means with his X rays, blood tests on all that. What these two have in common is the patient information, and they want to exchange that information using XML. Our job is to come up with example schema file, which acts as a contract between these two applications. These two applications agree on the schema file on men. Patient financials sends a patient X amount to patient clinic ALS it can use the scheme are to validate that XML and vice versa. Our business analyst has given us the following requirements. To start with, we should have a name in the schema for the patient is age, email, address, gender and a telephone number. These are the requirements she wanted as to get started with and as a typical business analyst. She also told us that we will have more requirements as we make progress 30. 30 XML Schema Data Types: the XML schema. Inbuilt data types allow us to specify what paper off data our example, elements and attributes can carry. These data types are defined by the W three C In the example. Schema specification all the major example. Processors and partners know about all these tapes, just like other programming languages like C C plus plus Java python. These data types started the numeric types bite, which can carry eight Britain teacher values Shot, which can take 16 bit integer values in picture that can take 32 bit integer values long that can take 64 bit into jerry values and then decimal, which can carry floating point numbers or decimal numbers. And we have several other types, like unsigned byte, etcetera, which we rarely use. But if you want to check them out, you can simply Google for numeric scheme. Are types are numeric example. Scheme are types and you'll find the entire list. So these Internet types here by chart in Texas, where they can handle different size off numbers, are different. Range off in bigger numbers. The second important type we have is the date type stocks with date puts can carrier date value date time, which can how both the date as well as a time in it time, which can carry just the time. Then we have several other values which we rarely use, like the day month acceptable, which can carry portions off the date like the day, month and so on. Finally, we have the string types important. Here is the spring. There are few other types, but again we really touch them. The string type represents set off characters, which you usually use to the present names and so on. All these in building types can be used or will be used by us to come up with our own simple types. Using the XML schema restrictions, we can use the inventor types, extend them and restrict the values which they carry, and then we can also use them to create complex types which are elements with sub elements are elements with attributes. They will see all that inaction in the next few lectures. To summarize XML schema specification from W three c defines inbuilt types that we used to mark our elements and attributes Once we mark them, those elements and attributes can carry only those type off values in the XML document. They are numeric types like bite short in tech cetera, date types on the string types. We use these types to come up with our simple and complex types. 31. 31 Assigning types to fields: In this lecture, we will assign the different in built a data types to our example. Fields is stocked with the name name is a set off characters, so that's easy. We can use the inbuilt string type. Age is numeric, so let's use in here. Email again. Is it set off characters String again? Gender For now, we'll leave it as a string type will be extending the string type later on. When you learn about simple types and restricted the value off gender to just how a few values, then the phone number. Let's have it as a string as well, and we are all set such that simple. We have a saying they're different in build pipes, which will be using when we create our scheme us for these fields. 32. 32 Namespace Basics: from learn what name spaces are and why we need them. Name spaces uniquely identify the elements on attributes off a maximal document. When we're creating a schema file, for example, let's say we are working on creating schema files for amazon dot com and ebay dot com toe handle their orders. The first step would be, and we defended schema. We will Assane a target name space for all the elements in the Amazon's order by using the target name space attribute from XML schema specification, and we will use a unique You are all from Amazon. It is always a good practice to use. You are a lot the company because it is unique across the world and across the Internet for the name space. And then, if we're defining a target name space for eBay, it would look like this where and to use the eBay snow, my name or the eBay's Worrell. Once we defend a target name space in their respective schema files, we can use a perfect instead off using this entire, you are all to qualify each element in the XML schema on next summer. Later on, we can use it perfect like this XML and a stands, for example, name, space. This attribute he's for maximum specifications. Colon. Whatever. Perfect. We want to use this perfect from that This point in time build rougher, toe this you are all and then we can qualify all the elements using this AMC instead off this entire Worrell. Similarly, if we're defending a perfect for eBay, here is the XML. Unless colon eBay is the perfect, this could be X y z or anything and then the actual name space. Once we define the target name space and qualify all the elements that we create with these prefixes and we created maximal document That XML document also should use the exact name space. For example, the order for Amazon the root element for order will have maximal unless colon a perfect defined for the name space on all the elements in that order will be qualified with the perfect. Similarly, the order for eBay will use the XML illness called on eBay and then all the elements inside again will be qualified with eBay's name space. For some business reason. If we have to use multiple orders from maybe an Amazon in a single XML Lachman, looking at the name space we know from which company are if the arteries from Amazon or is the order from eBay to summarize name spaces hours to uniquely identify the elements and attributes. In XML document, we create target name spaces in the schema file, which tells that all the elements in that scheme of and should follow Sartain name space and then instead off using the entire you are allowed to qualify each element in the schema . We use it, but if it's if you are from an object oriented programming background in the world off Java name space is nothing but a package where the nuclear classes and put them into a Sartain package. And in the dark net world, it is called name space very create classes and put them into name spaces. You will learn some advanced names based topics in sections later on, but for now, this information is pretty good for you to get started with example schema creation and they will be creating target name spaces perfecting the elements in that scheme off with those names basis 33. 33 Schema Creation: in this lecture will start working on our patients. Came a file by using the eclipse Islay launch the eclipse I d go to the file menu will be creating at New Project You are Project the name hit next and then your project The name Let's call it patient schema Click Finish Now that we have a project right click on the project let's create a schema file by saying new other This is very similar to how we have created XML files type in XML Under the example Wizards select the XML schema file instead off XML file click Next Choose our select the project under what you want to create the schema That is the patient schema Project your skim off island name That's call it patient The extension is Dark Access City and North XML XSD stands for example scheme our definition click finish Eclipse creates the minimum elements that are required by every schema file It is XML file as you can see a schema file Although the extension is dark Access City it is an XML file It starts with XML Declaration Alta Prologue line followed by the root element the one and only one route element called schema. The schema element, along with other elements which will be using later on, is defined in the XML, and this are the W three c name space exam illness Attribute stands, for example, name space, and it is used to specify what name space these elements belong to. If we define this XML anus on the root element automatically, all the chilled elements which we defined later on or which we use later on belong toe this name space. So all the example processors and parcels like the one which we are using an eclipse know about all these elements from the W three c name space. The target means space. On the other hand, Eclipse Gender did this as well to help us. The Stargate name space can be used to specify the name space for the elements, which we are defining for our application by default. It generated something called www dot example dot art, and it user the file name as though you are right patient. So let's change this. It's always a good practice to give it a domain name off our company because it will uniquely identify all the elements in our schema file. So let's call it, but the period dot com tomorrow. If we have 1/3 party application being used by the same hospital, which uses our application on if they have their own schema file, they would have defined our name space, which has their domain instead off our domain. That is the beauty off using name spaces. If we are using the same element named same like patient from within different schema files , looking at the name space, we can differentiate from there. That example is coming from our from which name space that application are that XML is being used from next time Maleness Penis is a perfect insert off. Using this entire, you are to qualify all the elements that were going toe for toe or create later on. We are defining a perfect scald examiner less colon T in this DNS usually stands for target name space, but we can use X y Z as well. It doesn't matter, but let's leave it as Penis. Copy this and dirty water because we're defining it. Perfect for that. You are paste it here and we are all set. I'll explain about this element form default in lectures later on To summarize in this luxury how created your patient dot Excessively filed by creating a patient schema project in Eclipse it is exam will find it starts with example Pollak followed by maximal schema root element from the W three c name space. We have also defined the target names place which all the elements will be creating. Let Ron will belong toe. 34. 34 Define Elements: in this lecture, we will fill in the XML schema file with all these elements will start by creating a root element. So let's go to the eclipse. I d under the schema element. The first element we need to define every time we come up with a schema file is the root element for our XML document. There should be one and only one route element. So it created using the element element from the XML schema name space. So there is an element from the excitement scheme and in space that we should use to create elements in a scheme or document. Let's give it a name. Let's call it patient B capital. We can close this element right here. Now we'll define a complex type because we need to how all these elements within on other element card patients. So the way we're going to do it is we're going to define a complex type called patient. And within this complex type, we can have all the elements like patient name each later but and so on. So in here we can have a sequence inside the complex type. We should always use sequence, a choice or all, which will be learning later on a sequence. Make sure that any elements that we define within this complex type should occur in the same very same order in which we defined them in the schema. We learn about other types, like all and choice in lectures later on, but you cannot directly define the elements under complex type. You will have to use a sequence are other options. So inside the sequence, the first element we want is the name. So let's give that element a name. Name is equal to name and type. We have decided for this is string from the XML schema named Space. We can close this element right here. We can copy this and pissed it five times. The second element we want is age. Age is off type int, as we have. They find it here, then email, gender and phone. Their field is email. String is fine gender. Let's have it as string for now. We'll use in numerous in later on. When you learn aboard the access the restrictions full. Let's leave it as string as well. Now we have created the XML schema patient type, but we haven't used it yet. If we don't refer to this, it is not used at all. So we have to use this complex type on the root element. We use the attribute called Pipe that is available on this is where the name space perfect will come into action. We use DNS colon, if you hit control space here. As you can see, Eclipse identifies what elements? What other elements are available in the scheme under this DNS name space and it uses that particulate pipe. Now, this complex type is used by our fruit element. So in this lecture, we have created our schema file by starting with the root element. Then we have created a complex type that can contain all the data that we want. We have used the inbuilt types like string in etcetera. Who will change these two types by using simple types will restrict the values for these fields in lectures later on 35. 35 Validating XML: now that we have examples came off ill defined. Let's create an XML document on Validated against this schema file. It is very easy to do that. Using their clips, I d go to the file menu say new either. It is very similar to how we have created a maximal file. Choose the XML file option under XML templates. Click Next, Select the project under which you want this file to be created. Give it a name, patient dot xml Click. Next is where the magic comes in. Instead, off creating example from scratch. Choose the second option here with say's Create XML file from it. XML schema file. Click Next Under the Patient Schema project, select the patient dot access City, The schema file, from which we want to create X. Someone click next eclipse Part is the skim off island. It identifies the target name space that should be used in the maximal that gets generated . Click finish. There we go. We have our beautiful like some of that eclipse has generated. Like every example, Lachman. It starts with the prologue, or XML, declaration, followed by a root element that we have defined in the schema, which is patient. This route element has all the other sub elements that we have defined in a complex type like name is email and all that. But the key here is that it has user the target name space that we have defined in the schema on the root element. So we always defined the target name, space or any name spaces on the route elements so that they can be used to rougher all the elements within that XML file. Instead of using this entire Worrell to qualify each off elements before and after there is a perfect score T illness. This again can be X y Z or whatever string you want to use for the perfect on. Every element from that point is qualified with colon using this perfect. A second important attribute here is the XML and this excess I. This exercise again is perfect for this name. Space W three c schema Instance name space. We're having it here because we had using it element called Kim on location. From this name space. It is different, but w three c. This Kim allegation tells the maximal processor where the schema file is located that can be used to validate this particular XML. In our case, it is the patient dot xsd. So the scheme our location usually follows with the name space with the space in between and then that schema file name. In our case, we have the schema file related to the external find. That is why we have a space and the file name. If it is that you are, you can use that entire. You are all in here. So if you have your skim off culinary Mork location, and if you want a point that you are, you can use that entire location here. Let's give these values some good value values for these elements. Name. Barrett Age. 34 24 34. Email barrettes Block a gmail dot com Gender Mail him four Number 1234567890 Of course, that's not a valid four number. That's not my phone number. Now, if we try to validate this stockman, it's very easy to validate. Right click, click on Validate and the Eclipse Processor runs this XML against this schema, and it says there are no errors. Are warnings, of course, because it was generated. Now let's change this age instead of using integer, let's try to use alphabets in here. Control s as soon as we save it. Eclipse Processor validate its again pointed on the error. It tells you that the value a off the element pianist age is not valid. That is the beauty off having it example scheme or document. Exchange it back. Another validation we can do here is we have your sequence demand it the order off these elements. So if I try to switch the order off these elements instead off pianists name on the top. If I put it after age, it complaints again. Viewpoint on there It says invalid content was found starting with element P unless age one off name is expected. So it is expecting in name when it validates this excellent. But it found age. That is what it is complaining about. So let's do a control Z. So it's that simple to generate xml Lachman in eclipse from a schema file on to validate it from this lecturing health seen how validation works. So in his offer, application can use their own XML processors and validate incoming example are outgoing example against a schema fight 36. 36 Simple Types Introduction: Now you know how to create a summer schema file on how to use the inmate pants. In this section, you will learn how to use the simple times on a couple of ways to restrict the values that our example elements can hold. 37. 37 Restricting the length: In this lecture, we will restrict the patient's name element to 15 characters. To do that, we'll be using the simple types available from the XML schema. So let's create our simple type by using the simple element. If you hit control space, Eclipse will help you. Simple type is from the XML schema named Space. Our specifications Give it a name. Let's call it string 15 cash so that we can use this type in other places as well. If required in this simple type, we will add a restriction. The restriction works is it derives from a base pipe from an inbuilt type. So the base we want is string type. So our name is off string type. But within this restriction, we can have different types of restrictions on what we're going to use is max length. The value is 15 toward our value. We do here. That is the value the which. That string will be restricted toe. We can close the Max lent right here. It is an empty element with attributes formatted. Now we have defined the simple type. We haven't used it yet, so let's use it in here instead, off pipe string we can say PNs colon. As you can see, Eclipse helps us again as soon as you type TMS colon. It chose us all the available pipes in this name space. We want to use the string 15 characters. Simple type. It's that simple. Now let's go to our XML and validated for the name. Let's type in some character, which will take this name beyond 15 characters. That's good enough, right? Click. Even before I rightly Quality Eclipse has already validated it. Sofa point on this error message here it says the value What our valley we have off element P in this name is not Valley. That is how we can restrict the length off XML element. Now it's back to normal once I change it. So in this lecture you have created your first simple type. Andi. How user That simple type of restricted the number off characters that the name field can take. We have used their restrictions that is available in a simple type which always derives from a base type, which is a in building type in the XML schema. This could be string into general Waterworld, whatever, and then there are different types off restrictions. If you go inside here and hit control space, you can see that there are different types off restrictions, mainland max length and so on. You can use any off this as required. I'll be showing a few more in the next few lectures. 38. 38 Using Enumerations: It is not a great idea. Tolo any value for gender. So let's restrict that, too. How only M on F m for male for female. To do that again will be using simple types from the XML schema. Let's create a simple type that's name it gender. Within this simple type, we're going toe use a restriction again. And in the restriction instead of using a Max land mainland Exeter were going to have a restriction which will use in numerous shin. So this restriction again derives from a base pipe string and in here in humiliation. Using this in Yuma rations, we can define values. The first value a warrant is am I will flows This enumeration right here copied is in, um, oration basted on the second value I want is if we can define any number off values using the enumeration element. Insider restriction. Now let's use this gender type on. Refer to it in here for gender, the type will be instead offspring TMS colon controlled space. There we go. Gender Save it. Go to the patient or xml Now instead, off em here for gender, for Trey to use X eclipse immediately validates it see the error, the value X off element pianists. Gender is not valid, so let's change it back toe m Save it. We're back in business. In this lecture, you have used another restriction type available from the excitement schema, simple types that is in new Marais. Shin derives from the base type string you can even derived from indigent and how numerical values here, if required, and then we have refer to it in the complex type for the gender. 39. 39 Creating Complex Types Introduction: public states on those that have a that changed elements are introduced in this section. You will learn how to create complex types on how to use one complex time 15 another complex man. You'll also learn home to control the order in which the elements can occur in an excellent document as well as the number off paints. A particular element cannot occur inside a excellent talking. 40. 40 More Requirements: our business analyst has finally got back to us with the new set of requirements, along with the basic patient information. She also wants us to capture the payment pipe that the patient can use. That is either he's paying by cash or he's using it insurance that he has coverage under. And if it is insurance, we have to capture the limit that insurance property as well as the provider very simple requirement will be using these requirements and coming up with the scheme ailments for these requirements while learning how toe use complex types in other complex types and also to control the order off elements within complex type. 41. 41 Making a choice: in this lecture will come up with the payment type scheme I element complex type who are learning how to use the XML schema Choice element Lord of the Eclipse, I d. Let's go to our schema file in here. Let's define a new complex type. Call it payment type Inside this complex type will have two elements instead of using a sequence we're going toe, use a choice. So the choice in XML schemer tells external processor that one off these elements should definitely be there. It's not mandatory for all the elements to be there in case off sequence. They should occur in the exact order and all the elements should be there at least once. But in case off choice, as long as one of the elements is there, it will not complain. Two elements were going to have in here is element number one name cash type. Let's have it as a base, Eamon, you can close the element right here. The second element will be name is equal to insurance. Closed element right here will define the insurance element itself as another complex type because we'll have to provide the limit under Breuder. So it will have to be another complex type well defined that in the next lecture, when you learn how excessively all works. 42. 42 XSD ALL: lecture. We have defined the payment type complex type, which uses two elements. Cash and insurance. We haven't defined the insurance pipe it. So let's define another complex type by learning how to use Xsd all so create a complex type. Let's name it insurance in here we'll have all instead of using choice our secret. This time we're learning how to use all all means. All the elements should occur at least once, but the order doesn't matter. In case off sequence, they should all occur and also the order in the order in which they are mentioned in the schema in here. Inside all, let's define the first element. Name is equal to provider. That's how lawyer case and type is equal to string step providers name like Group Lost Blue Shield and so on. Second element is the limit, which this insurance from where I can pay the maximum limit name his limit on the type. Let's have it as a decimal again, this multi from XML schema. So we have defined both their types. In the next lecture, it will see how to use complex types in other complex types 43. 43 Complex Types in other complex types: now that we have defined all the complex types, like the payment type on the insurance type. In this lecture, you will see how to use complex types within other complex types. So these complex types don't make any sense unless they're used somewhere else. So the insurance let's use the insurance to mention that pipe here for the insurance underpayment type type is equal to if you're type TNS 100 space. Is that insurance like that type we're done on, then this payment type should be defined for the patient here inside the sequence. So let's se element name is equal to payment type type is equally toe again. DNS controlled space. The payment that simple. Just like how we have used simple types, we can use complex type inside other complex types to summarize. We have defined payment type using excessively choice. So these elements, one of them, should be there either one of them on, and we have used access the all to come up it, the complex type for insurance information. All of these elements should be there, But the order doesn't matter 44. 44 Controlling the number of element occurances: by default. All the elements that we define in XML schema should appear once and only once in the XML document in this luxury will learn how to control that will use the email and the phone fields to learn how to do that. Let's say we want the email field to be option. We have a requirement wearing the patient Need north you his email information. If I try to delete the email from this XML right now, as soon as a diluted save it, there is another maximal processing. Eclipse says that it is expecting email, but it phoned gender to fix that. Go back to the patients Patient Art Access City On the email element, we can use an attribute from the summer schema. Call Men occurs. Men control space will give us mean occurs. Select that by default. The value is one to make it zero meaning email now is optional. Cannot get a minimum number off zero times go back and the other is gone. So now that email has become optional. Now we want the patient to enter more than one phone number. Let's a cell phone number home for number, office number, etcetera. we can try that by having multiple phone numbers with the current schema. Copy paste a phone number three times twice. You see another immediately. It says payment type is what is expected, but it has found phone. So to fix that, we can use the Mac suckers. Max occurs three, so we can have three different phone numbers Now. If I try to enter another phone number here immediately, it will complain. Only three are allowed to allow that we can use something called unbounded. There is inbuilt value in XML schema. All the XML processors know about these values unbounded. So if I say I'm more under this particular element can occur infinite number off times. If I go back here, no more letters. We can have any number off four numbers now, so it's that simple. You can use the miniatures on Max actors on any off the elements defining your ski mining or complex types are anywhere a main complex type and control the number of occurrences offer element by default. The element should be there at least once and only once 45. 45 Validate XML: in this lecture. Now that we have the entire schema file ready, we will recreate the XML file from the schema file and see how the validation works. So let's delete the current XML file, right click on it. Deleted. Okay, that's recreated. Rightly called the project. Say new. Are there XML file. Next, choose the project patient Schema is the project. You're filed a name again. Let's call it patient Lord XML. It next create XML file from an exam. A schema. Choose that option. Next, choose the schema file. Next, leave the default options, as is click finish. Now, if you see we have the additional payment pipe option available here on by before it is cash, we can also add the insurance element in here. So let's give it some value values. First. Start with name. It's that before email, but it's blawg at gmail dot com. Gender is fine. Telephone number 1234 Women type cash is fine for now. Let's say 8000 right click Validate. The document off course is valid. Now let's try to but the insurance in here instead. Off cash. Remove this cash option and say DNS control space insurance. As you can see, a clips only gives you the options that are available. We can either use cash or insurance the insurance wind on the insurance to see that it says the content type insurance must have a provider and that limit. So let's see if the order works. Let's try Penis limit first, let's say if $10,000 is the limit from this provider and then let's have the second element Penis provider Blue Cross Blue Shield, one of the good providers. As you can see, there are no validation errors, even if you right click and save validate. There are no others are warnings, so the order doesn't matter, and we use Access City all on Monday when we use choice. Only one of the elements should be there, Like in this case, we have used insurance earlier, it was cash. So we have successfully used complex types inside other complex types as well as you know how to use existing choice access to all and the most powerful and frequently used existing sequence to mandate the order off elements as well as the occurrences off all the elements 46. 46 ElementFormDefault: in the very first schema Hands on lectures. How promised Do that. I'll come back and explain Award this element form default Attribute on the schema, the root element off every skimmer fight. So here I am to keep their promise. This element form default and the value it has qualified tells taxable processor that each and every element in our example document which follows the schema should be perfect with the name space. In this case, we're using it perfects and our name spaces different on the top. So if I try to remove this TNS from here on board sites immediately, the maximal process complaints that element that it was expecting is name along with the name space. But it found something called name so it doesn't even know about this element because it's not being qualified with the name space. Let's go to the schema. We can use a value called unqualified Save it. Come back door maximal. Now that error is gone, so we no longer need to qualify the elements in our XML with the name space. But you see that all the other elements will know how errors starting with age because we have prefix date with the name space are we are qualifying it using the name space. There's that simple to use the element form the fort. Let's make it qualified and backdoor maximal. Let's qualify everything. It's up to you how to do it. Either you can have it as qualified as our unqualified. 47. 47 Attributes Introduction: any news on additional special meaning to the data, their elements and close In this section, you will learn how to create attributes in a schema file and also hold arrested the values off attributes using a simple type. 48. 48 Adding Attributes: in this lecture, you will learn how to add attributes to your scheme. Are types so in here for the patient root element. I want to add a new attribute called idee so that it will uniquely identify patient. Do that, go to the complex type off the patient on after the sequence will be using an element called attribute Control Space. There you Go, a tribute from the XML schema, named Space from W. Three c specification. This attribute can have a name using which we specify the name for their tribute. Haiti, and also the type can be inbuilt type like in P j. R. We can create a simple type. For now, let's use the inbuilt indigent pipe will restrict it In lecture Laurent, Get close the attribute, using the shorthand notation. Now, if you go back to the patient X amount on the patient element before it closes, we can have a idea tribute and the value off. It can be 123 or any integer value. So it's that simple to create, attributes it in the complex types we can use element called attribute and give it a name pipe 49. 49 Required Attributes: in this lecture. Oh, to make an attribute required by default. Any attribute that we add to XML schema is optional in the XML document. For example, if I take over this, I really want to three. From here, the validator hard maximal processor does not complain because we haven't specified any attributes that will make it required. So to do that on the attribute hit control space and you will see the various attributes that are available to add special meaning to the central will use the use a tribute by default. The value for it is optional, which makes this attribute. Optional on XML is created but will use the value called required within double courts required. All these values, the required and optional, are defined in the XML schema named Space Maximal schema, specification and all the XML processors. No aboard these values. Now if you go back to the patient Nordic Cemal, he will immediately see an error, it says. Attribute idee must appear on the element PNS patient, so let's add that mandate re a tribute now give it value 123 and the other is gone. Such that simple to control weather and attribute is optional are required by default. It is optional 50. 50 Assigning SimpleTypes to Attributes Values: our idea. Tribute currently uses in Built in pigeon type from the XML schema. Let's restrict the I D to how values off 0 to 9. Any number off 0 to 9 digits. To do that will create a new, simple type, and they will learn about a new restriction that can be used. So let's go to the simple types on the top about the simple times. Create a new simple type. Let's give it a name I D, and in here will be using a new restriction. The first step to create a restriction, as you know by now, is to you were based type, which is in for us because ideas in teacher heuristic the values we can use patterns or regular expressions. So there is a pattern within the XML schema that we can use a loser. Simple regular expression here, zero to mine start so you can play around with the patterns you want. This is just to demonstrate that there is a pattern type available in the XML schemer that we can use to restrict the values off any fields. Now, instead of using mpg, let's refer to the new type. Remove this into gear we can refer to I d That's a Penis idee. That's it. It's that simple On our I d now can only have a loose from 0 to 9. 51. 51 Include and Import Introduction: from the excellent schema hands on lectures, you have learned the basics off exam unnamed spaces, that is. The other was to unity. Qualify the elements and attributes in excellent scheme US and X amount Feiss from the lectures in this section you will get a quick recap off it, Summerlin spaces. And then you learn how to use the example Schema include on import toe. Use one schema file inside another scheme off. 52. 52 Namespace Recap: in this lecture, I will recap about the name spaces before you use them again for including on importing a name. Space uniquely qualifies the elements and attributes in our scheme US and XML files, for example, the XML anus stands, for example name space and it can be used to define the Defour name space for all the elements that are used in any XML file. In this schema file which is an XML file intern, we use the scheme I element of the complex type element element sequence. And all these elements are from the W three c name space. So all XML processors know about these elements which are defined in this name space. We have defined their target name space for ailments which we are defining here on which will later on appear in an example document as our domain name slash the object. We're working on our the requirement we are working on. It's always a good practice to use the domain name, although it's not required. You know, my name is unique for a company and it's always a good practice to use it. Once we define the target name space, the next thing to do is to define a perfect for the name space so that we can use their perfect to qualify the elements later on when we use them In our schema prefix we use exam illness which stands, for example name space, colon, whatever prefix you wanted me nor VPNs. It can be X y z and then the name space which we are defined here. And once we define our elements, all these elements fall into this target name space to use them in other complex types, we use the perfect we have different on the top. If we have this element form, default as qualified will have toe qualify All our elements in XML document with the prefix and we use the elements in the XML Lachman we define a name space here as well. With a prefix again, this perfect need not be Penis. It can be a B c, x, y z, or whatever and then we use their perfect to qualify all the elements in our XML document. The next two lectures, he will see how to include example scheme I elements from same name space on how to import elements within a schema from a different schema with a different name space altogether 53. 53 Including Other Schemas: as we get more and more requirements and as the file size off this patient access DeGross. We have too many types in one single schema file, which makes it hard to maintain or make any changes to it. That is where the access city are. Examples key must include Element comes in and it allows us to include one schema file inside another schema file so we can move some off. These complex types are simple types to their own scheme our files and then we can include that file in this schema and use all these elements. Let's move this payment pipe element of the complex type from this schema to an other schema file. Let's create a new scheme, a file called patient type by right clicking on the patient Maximal Project se knew. Go to other type. In example Schema file like mixed. Select the Project Patient XML You This key my name. Let's call it payment pipe finish. We have maximal declaration and schema root element in the scheme. Ah wrote element. We can cut these two complex types from here the payment type on the insurance because insurance is used in turn by payment type and based them here in this new schema file. Think I'll corporate an extra element? Let's cop cut it back. Put it back to the original file and immediately you see that it complains the patient Access D complaints about the payment type because we have moved to another file. Let's first change the name spaces in this new file from this example. Example. For example, Lord Argh, too. The same name space which we have here. This is important when we are including the name spaces should be seen so that our get names piece instead of payment. We'll make it patient patient as well. For example, honesty and miss and we are done with this file to resolve the error here and to include the files in through the new filing The patient are toxicity right on the top. Inside Lasky, my element we lose include Element that is available from XML schema. We can close it right here using the shorthand notation and for the scheme, our location. Give the name off the file because it is related to this file payment type dart xsd and immediately the artery's gone. So the example processor includes this file uses the complex types that are available in here for the payment type information. Since the name space in both of them are same, I'm able to use the DNS. DNS here points to the same name space product operated dot com slash patient, which we have used even here. So all these complex types defined here fall into this name space on we are including it and using the same perfect which points to the same name space to summarize. In this lecture, we have mood the complex types for the payment type to a schema off their own so that our schema now is not cluttered with too many types, and it is easy to maintain. 54. 54 Importing From Other Schemas: in the previous lecture, you have learned how to include the elements from different schema files in tow schema file using the include element. They include Element works. The elements are from the same name. Space that is the payment type was from the same name. Space, but articulated dot com slash patient on the patient not accessed is also from the same name space. But if we want to import elements from different names places, then we'll have to use the import element that is available for that. Let's consider example here. Let's move this I d. Field to wear different schema with a different name space because I d can be used for a patient, for a doctor, for insurance company, even for the hospital. So I d can be used across Kiemas. So it is not a good idea to have this simple type in the patient. Dark xsd Cut it from here. Create a new scheme on file right click on the patient XML say new out there except schema fired. Next, select the Project patient XML give it a name Common dot Access City. It finished until shift F. So far, Matt, based on simple type in here on the name space. We'll use a new name space, but we'll copy the You are all from here from any off our current scheme of files. But a TPL dot com The Ural remains the same, but we will leave the common as is the instead of a patient at the end. Now we have a new name space called Common within an organization we can how multiple name spaces like this for each team are for each model that we are working on again here for the prefix as well, we'll have to use the same name space which we are using here. Same target name space we're using here. So now this idea element belongs to the common name space are not the patient name space to use this in the patient access city. As you can see, that is an error because we have cut the ideal men. There is no simple type called idee in the schema now, so let's fix that by using that import element. But I make some of scheme and its place close it right here using the shorthand notation import takes The schema location is one that reward. Similar to include common dot excessively is the file path which is related to this file. Secondly, we also need to defend one more attribute Corn name space. We need to tell from which name space We are importing the elements to copy this whole name space basted here on we're done with the import, but the other is not gone yet because we need to use this name space to prefix this particular qualified this particular attribute to do that. Let's define a new perfect here Example In s which stands for, like, someone in space. Colin, we can call the perfect whatever we want. Let's call it. See, You can also call it common if you want or C is equality double courts the name space for new schema file now instead, off PNS here we can use common on data is gone. So in this lecture, you have learned how to new elements are how to use elements from different name spaces across Chema files. We have more the i d the simple type I d into a common not access city. Then we have included that are sorry we have importer that in the patient not excessively. We have defined that new perfect for the new name, space and user that perfect against the I D element.