An XML schema depicts the structure of an XML document.
XML structures schema define a class of documents by using schema components to constrain and provide meaning to the documents, usage and relationship among their parts, like, data types, elements and attributes in addition with values. It provides the schema for specification for further information of document. Thus formally can be said that,
“XML Schema: Structures can be used to define, describe and catalogue XML vocabularies for classes of XML documents.”
XML Schema is an XML-based alternative to DTD. And it can also be called XML Schema definition (XSD).
Why XML Schema
- Provide more influential and flexible schema language as compare to DTD
- Represent XML document syntax in XML language
- XML tools can be readily used
- Support non-textual data types
- vital role in B2B, e-Commerce
- can easily manage complex syntax
- With DTD, you cannot specify “a value of an element is in the range of 10 to 100”
Valid Vs Schema-Valid
Initially with XML 1.0, XML Schema was not the part. So that the documents that are validated with DTD syntax are call “Valid” and on the contrary, documents validated with XML schema are “Schema-valid”. Additionally, XML document that conforms to a specific XML schema is “instance document” of that schema.
Definition and Declaration
Definition is to create new types and declaration is to use that definition.
-
<!– Definition: Creation of a type –>
-
-
<xsd:simpleType name="zipUnion">
-
-
<xsd:union memberTypes="USState listOfMyIntType"/>
-
-
</xsd:simpleType>
<!– Declaration –>
-
<element name=zips type=“zipUnion”>
-
The <schema> Element, Simple Types & Complex Types
The <schema> Element
The schema element is the root element of every xml schema document.
-
<?xml version="1.0"?>
-
-
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
-
targetNamespace="http://www.w3schools.com"
-
xmlns="http://www.w3schools.com"
-
elementFormDefault="qualified">
-
…
-
…
-
</xs:schema>
Simple Types
A simple type cannot contain child elements or attributes, so it can only contain text. Well, it can be one of the following types as well, Boolean, string, date etc. or some custom type.
-
<xs:element name="xxx"/>
-
To define a default value use default attribute and for fixed use Fixed attribute as show in following examples.
-
<xs:element name="name" default="papu"/>
-
<xs:element name="name" fixed="mike"/>
Note: XML Schema specification defines a number of simple types for values, as shown in Table: Predefined simple types of values
Complex Types
Complex types contain other elements and/or attributes. There are four kinds of complex elements,
- empty elements
- elements that contain only other elements
- elements that contain only text
- elements that contain both other elements and text
Defining a complex type,
-
<xs:element name="employee">
-
<xs:complexType>
-
<xs:sequence>
-
<xs:element type="xs:string"/>
-
<xs:element type="xs:string"/>
-
</xs:sequence>
-
</xs:complexType>
-
</xs:element>
And its declaration should be like this,
-
<employee>
-
<firstname>John</firstname>
-
<lastname>Smith</lastname>
-
</employee>
Importing Sample Schema with no schema location
<!– This is the same schema you saw in Example1 –>
-
<xsd:schema
-
-
targetNamespace=‘http://www.SampleStore.com/Account’
-
-
xmlns:xsd=‘http://www.w3.org/1999/XMLSchema’
-
-
xmlns:ACC= ‘http://www.SampleStore.com/Account’>
-
-
<xsd:element name=‘InvoiceNo’ type=‘xsd:positive-integer’/>
-
-
<xsd:element name=‘ProductID’ type=‘ACC:ProductCode’/>
-
-
<xsd:simpleType name=‘ProductCode’ base=‘xsd:string’>
-
-
<xsd:pattern value=‘[A-Z]{1}d{6}’/>
-
-
</xsd:simpleType>
Importing a Schema with schemaLocation
The PART namespace needs to be imported using the import declaration element whose schemaLocation attribute specifies the location of the file that contains the schema because
- Is not a well-known namespace
- Is not a targetNamespace
<!–XML Schema fragment in file schema1.xsd–>
-
<schema targetNamespace=‘http://www.SampleStore.com/Account’
-
-
xmlns=‘http://www.w3.org/1999/XMLSchema’
-
-
xmlns:ACC= ‘http://www.SampleStore.com/Account’
-
-
xmlns:PART= ‘http://www.PartnerStore.com/PartsCatalog’>
-
-
<import namespace=‘http://www.PartnerStore.com/PartsCatalog’
-
-
schemaLocation=‘http://www.ProductStandards.org/repository/alpha
-
-
.xsd’/>
-
-
<element name=‘InvoiceNo’ type=‘positive-integer’/>
-
-
<element name=‘ProductID’ type=‘ACC:ProductCode’/>
-
-
<simpleType name=‘ProductCode’ base=‘string’>
-
-
<pattern value=‘[A-Z]{1}d{6}’/>
-
-
</simpleType>
-
-
<element name=‘stickyGlue’ type=‘PART:SuperGlueType’/>
Tools for manipulating XML Schema
Several free and commercial tools are available,
- Netbeans 5.5 and higher
- XML Spy
- Apache Xerces
- DTD to XML Schema Conversion Tool
Resource:
http://www.javapassion.com/webservices/#Web_Services_Overview
Posted in
Tags: 
Thank you guys, I love this place, you have put a lot of work into it as I see, awesome… good work mods. – Offshore Company Formation
Maybe this will be good for her
HA! After reading you site, Your site is very useful for me .I bookmarked your site!
It does seem that everybody is into this kind of stuff lately. Don’t really understand it though, but thanks for trying to explain it. Appreciate you shedding light into this matter. Keep it up
Haha, great information you write it very clean. I’m very lucky to get this details from you.
Hey, Great article,i hope can know much information About it!
Good share, great article, very usefull for us…thanks.
Demonstrate the spirit of free style…
My site is about the freestyle culture website, welcome to interested friends to visit!…
Awesome site I’m very glad I wandered here through yahoo, Going to definitely need to add this one to the list
Howdy there,I obtain that your weblog is incredibly informative and useful and we wonder if there can be a possibility of obtaining More writing like this on your website. If you willing to support us out, we will be willing to compensate you… Best wishes, Fermin Over
been visiting your blog for 3 days. really love what you posted. by the way i am doing research regarding this area. do you know any good blogs or perhaps forums in which I can learn more? thanks a lot.
Hi , really like the blog. I found the answer to uneven gaps between paving and patio stones . These spacers from GapFast.com are the easy way to an excellent, even patio.
Thank you, I’ve recently been looking for info about this subject for ages and yours is the greatest I’ve discovered till now. But, what about the bottom line? Are you sure about the source?
Hi there, just became aware of your blog through Google, and found that it’s truly informative. I’m going to watch out for brussels. I’ll appreciate if you keep going this in future. Numerous people will be benefited from your writing. Regards, !
Hi, I think your website might be having browser compatibility issues. When I look at your blog site in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, great blog!
Hi, I think your blog might be having browser compatibility issues. When I look at your website in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, very good blog!
Wonderful post but I was wanting to know if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Thank you!
This is not my first time here, and again you know what you’re doing, keep it.
Attractive section of content. I just stumbled on your weblog and in accession capital to assert that I get in fact enjoyed account your website posts. Any way I will be subscribing to your augment and even I achievement you access consistently fast.
Great job, I enjoyed reading this !
My partner and I absolutely love your blog and find the majority of your post’s to be exactly what I’m looking for. Does one offer guest writers to write content for you? I wouldn’t mind producing a post or elaborating on many of the subjects you write about here. Again, awesome website!
Merit for posting this informative article. I’m definitely broken together with on the struggle to go looking out necessary and intelligent cause during this issue. Everyone now goes to the very far extremes to each of drive domestic this viewpoint that each of: most people else in the planet is wrong, or perhaps a couple of that everyone although them won’t surely understand the way it is. Many thanks for ones limited, relatable facts.
Hope that you can impart much more learnings to us.Searching forward for that.
apad gm10
deberry.de
This is my quite 1st time I have come by your site. I revealed a perfect deal of intriguing points in your web site.
My wife and i know you have made many definitely appealing topics! Not really as effectively many folks would really envision concerning this the way you just did! I actually am truly impressed that there is so much concerning this issue that has been displayed and you created it so properly, with so highly class! Excellent, man! Really great points right here.
Dubstep has only has one way to go and that is UP, BIGGER HARDER AND DIRTIER!!! Really nice post man, thanks!
Dot Exe has to be my favourite dubstep artist. nice post, thank you!
Outstanding, that’s exactly a few things i was ready for! You may preserved everyone many of get the job done
That is a good things, I am very willing to read this article, and I consent with the points of this post. I think this is the best impression. I would like to do something after reading it.
I generally agree with your opinions. We all obtain a benefit from this wonderful post. This site is excellent. I have figured out a lot of things from here. Thank you.
this is a useful thing 4 sure Here’s some thing to make you smile: Thought for the day? : Daddy, what does FORMATTING DRIVE C mean?
Simply put i consequently enjoyed your site. Good subject matter. Please continue to keep placing this kind of excellent cotent.
I am glad for writing to let you know with the wonderful experience my friend’s girl went by means of reading the weblog. She figured out several pieces, most notably how it truly is like to have a great helping style to get a lot of far more smoothly completely grasp several specialized issues. You truly did much more than visitors?expectations. Thank you for displaying those great, dependable, explanatory and in addition cool guidance on this topic to Lizeth.
Very nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed browsing your blog posts. In any case I will be subscribing to your feed and I hope you write again soon!
The best things in life you hold in your heart, not in your hands.
Hiya there admin, I just wished to firmly leave a short comment to actually admit that in fact I admired your particular blog post. Thanks!
Wohh just what I was seeking for, thanks for putting up.
Have you guys checked out my dubstep distribution blog yet? I update it like 32 times a day
Hello my loved one! I want to say that this post is awesome, great written and include approximately all important infos. I’d like to peer extra posts like this.
A friend of mine advised this site. And yes. it has some useful pieces of information and I enjoyed reading it. Therefore i would love to drop you a quick note to express my nice one. Take care
Preserve in the fantastic do the job. You are cracked towards certainly, there thoughts and opinions. Superb web log the following, i will be yet studying
The next time I read a blog, Hopefully it does not fail me as much as this one. I mean, Yes, it was my choice to read through, however I really thought you’d have something useful to say. All I hear is a bunch of crying about something that you could fix if you weren’t too busy looking for attention.
I became on my way for vacations an important partner who’s from a coma for the medical center when a vehicle accident. Despite the fact that travelling some cientos As i surely could reflect on the way fundamental its to make sure your loved ones every single day exactely how much that they suggest for your requirements plus the worth regarding lifespan generally speaking.
Superb, simply dazzling! Brilliant to work out accounts that may have you feeling living. To bad this time we do not acquire greater number of these. This approach created the technique completely happy……….
Cool article indeed. We have been waiting for this tips.
Like this if Hot Dogs are a part of your plan this Memorial Day Weekend
you are really a good webmaster. The website loading speed is amazing. It seems that you are doing any unique trick. Moreover, The contents are masterpiece. you’ve done a great job on this topic!