XML Files with Linked External XSD Files

This section provides a tutorial example on how to store XSD statements in an external file, which can be then linked to XML files. The external XSD file should also be a well-formed XML document.

XSD File: An XML file that contains XSD statements that define elements, attributes and entities of a schema for XML files.

Instead of including XSD statements inside an XML file, we can also store XSD statements in an XSD file, and link the XSD file to the XML file.

Let's write our first XSD file to define a schema for our "Hello world!" XML file. Here is the XSD file, hello.xsd:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <xsd:element name="p" type="xsd:string"/>
</xsd:schema>

This XSD file needs to be linked to the XML file, hello_xsd.xml:

<?xml version="1.0"?>
<p xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="hello.xsd">
Hello world!</p>

Note that:

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 XML-JSON Document Conversion

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

XSD (XML Schema Definition) Introduction

 What Is XSD (XML Schema Definition)

 XML Files with Embedded XSD Statements

XML Files with Linked External XSD Files

 Validating an XML File against a XSD Schema

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

 Java Implementation of XSLT

 XSLT (XSL Transformations) Introduction

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 PHP Extensions for XML Manipulation

 Processing XML with Python Scripts

 XML Notepad - XML Editor

 XML Tools Plugin for Notepad++

 XML Plugin Packages for Atom Editor

 XML 1.1 Changes and Parsing Examples

 Archived Tutorials

 References

 Full Version in PDF/EPUB