XML Schema Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.00

Creating and Editing XML Schema Documents

This section describes a tutorial example on how to create and edit an XML Schema (XSD) document with XMLPad.

XMLPad can also be used to create and edit XML Schema (XSD) documents. Here are the basic steps of creating and editing an XSD document:

1. Run XMLPad, and click menu File > New. XMLPad shows a list of XML document types for you to select, XML Document, XSD Schema, XSL Stylesheet, Document Type Definition, WSDL Document, and RSS 2.0 Document.

2. Double click on the XSD Schema icon. XMLPad shows the "Create new W3C Schema wizard" dialog box:
XMLPad - Create XSD Documents

3. Leave the Namespace field blank and click Next on the first screen.

3. Do not select any schema extension on the next screen, and click Finish. XMLPad will create a new XSD document named as "Untitled.xsd" with two lines:

<?xml version = "1.0" encoding = "utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified" attributeFormDefault="unqualified">

</xs:schema>

5. This is a nice starting point, but it has no XML elements declared. So let's modify this XSD document to be the schema document for our simple HTML document created in the previous section:

<?xml version = "1.0" encoding = "utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="qualified" attributeFormDefault="unqualified">
 <xs:element name="html" type="htmlType"/>
 <xs:complexType name="htmlType">
  <xs:sequence>
   <xs:element name="body" type="xs:string"/>
  </xs:sequence>
 </xs:complexType>
</xs:schema>

6. The last step is to click menu File > Save As. And save this XSD document as \xsd\first_html.xsd.

To fully understand this XSD document, you need to read other chapters in this book to learn XML Schema language syntax. As a quick summary, here is what being defined in this XSD document:

  • The conforming XML document must have a root element named as "html".
  • The root element "html" must have one sub element named as "body".
  • The "body" element must have content in "string" data type.

Sections in This Chapter

Installing WMHelp XMLPad Pro

Creating and Editing XML Documents

Creating and Editing XML Schema Documents

Assigning XML Schema to XML Documents

Validating XML Documents with Assigned XSD

Validating Non-Conforming XML Documents

XMLPad Crash When Validating Non-Conforming XML Documents

Generating XML Schema Diagrams

Dr. Herong Yang, updated in 2007
Creating and Editing XML Schema Documents