Home
Username:
Password:
Microsoft Visual Studio .NET Tutorials

Markup Languages / Well Formed XML Documents pt. 2




Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com’s entire library of video tutorials.


Learn More

Subtitles of the Movie

Now this document is well-formed or should be, well now just a minute, for the time being though let's see what the XML Designer can do for us, we can have it actually write out in the XML schema language an XML schema based on how it found the data. It actually interpreted the tags, the elements, the attributes, and the values and so forth to create it's best guess at a reasonable XML schema for this XML document and and it created it in a XSD file named XMLFile2.xsd. Let's go back to our XML document and we can see that it has put in an XML name space, These are the attribute xmlns=”http://tempuri.org/XMLFile2.xsd, that's the location, the temporary location where this file can be found, and from that, from this XML schema, we can not only tell if this document is well-formed, we can also validate the document. Before we validate it we should save it, so go ahead and save the file, and go to XML, validate XML data, and you'll see down here on the status bar, no validation errors were found. That means that our XML document is not only well formed, the elements and attributes and the values of the attributes that we've used are valid according to the specifications written in XMLFile2.xsd. So let's go back to our XSD file, and we will take a look at, first of all the XML document, behind this visual display. If you go down here to the XML button, and we click the XML button, we'll see the actual XML document that makes up the schema. Now this is all created and written automatically by the XML Designer in Visual Studio .NET. It's very helpful in that respect, as long as it can interpret the XML that you've written. When we get into databases you'll find that you can also have XML schemas created, based on databases and the relations between tables and your databases in this program, it's very useful. So let's go back to the schema view and let's take a look for a minute at some of the elements, and attributes and values that we've created here. We've got the customer element, customer element is allowed to have order elements, and for content it's allowed to have an attribute denoted by the a, that accepts data type values of string, and below that, a child element for the customer is the order, it has a child element of order item. It has three attributes, number, total and date. The order number though is set to a data type of string, and we want to change that to a positive integer, because all of our order numbers are going to be positive Integers. The total should be a numerical data value of some kind let's see what we've got here. These are all data types that are allowable in the XML schema language, and we've got an integer, and so on and so forth. Okay, there we go double or how about decimal, let's use decimal, for the date data type and I believe we have an actual date data type here, yes we do, and let's go down to the individual order items, now the quantities are always going to be a positive integer, price we can set to decimal, there we go, and we save that. So now we have the correct data types for the elements that we have in our schema, and if you go up to the schema menu choice, you can see that there is a choice there for adding new attributes, attribute groups, any attributes, if we were clicked on an element, we could add a new element, as a child element of this element, we could make groups and so forth. And notice that there's also ways to create keys, primary keys and form keys, which are database terms, and relationships, which is also related to the database term relational database. So as you can see there are a lot of tools in the XML Designer for not only creating well-formed XML documents, but also for creating schemas from those documents, and for working with data in a way that it can be validated. And this is your finished, not only well formed but valid XML document.

Tutorial Information

Course: Microsoft Visual Studio .NET
Author: Dave Mercer
SKU: 33420
ISBN: 1932072276
Release Date: 2003-04-01
Duration: 7 hrs / 101 lessons
Work Files: Yes
Captions: For Online University members only
Compatibility: Vista/XP/2000, OS X, Linux
QuickTime 7, Flash 8

VTC Sign up & Benefits

  • Unlimited Access
  • 98,729 Video Tutorials (23,265 free)
  • Video Available as Flash or QuickTime
  • Over 1026 Courses
  • $30 for One Month Access
  • Multi-User Discounts Available