XSD (XML Schema Definition) and XML Documents

The purpose of this assignment was to:

The description and my solution of the XSD(XML Schema Defintion) - assignment can be viewed at the bottom of this page.

What is an XML Schema Definition?

The purpose of an XML schema is to define the structure of an XML document. It does this by defining the allowed components of a document, just like a DTD does.

An XML Schema is sometimes referred to as XSD, which stands for XML Schema Definition.

XML Schema Definition Language is a language written in XML.

An XML Schema is used for defining:

Benefits of XML Schemas

XML Schemas Support Data Types

XML Schemas support for data types makes it:

XML Schemas are XML-based

Since XML Schemas are XML-based:

XML Example Document and Example Schema

This is a simple XML document implementing a "message":

<?xml version="1.0" encoding="ISO-8859-1"?> <message> <receiver >Buck</receiver> <sender>Lenny</sender> <subject>Welcome</subject> <content>Welcome Buck!</content> </message>

and this is an XML Schema to describe it's structure:

<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.webpelican.com" xmlns="http://www.webpelican.com" elementFormDefault="qualified"> <xs:element name="message"> <xs:complexType> <xs:sequence> <xs:element name="receiver" type="xs:string"/> <xs:element name="sender" type="xs:string"/> <xs:element name="subject" type="xs:string"/> <xs:element name="content" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>

Because the message element contains child elements, it's is a complex type. The child elements receiver, sender, subject and content are simple types since they don't have other elements as child elements.

The Reference to the XML Schema

This is the message document now with a connection to (reference to) the XML Schema above:

<?xml version="1.0"?> <message xmlns="http://www.webpelican.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.webpelican.com message.xsd"> <receiver>Lenny</receiver> <sender>Bobba</sender> <subject>I like to hate XML Schemas</subject> <content>I've grown to like hating XML Schemas!</content> </message>

Assignment Description

Put constrain on the cv-template from XML Basics by using an XML Schema.

My solution, Assignment Files

«  Previous Next  »