XML Files with Embedded XSD Statements

This section provides a tutorial example on how to include XSD statements inside XML files. Embedded or inline XSD statements should appear inside a parent element and before target elements the schema is applied to.

Can we embed XSD statements inside an XML file similar to DTD statements? The answer seems to be yes. An embedded XML schema is also called an inline XML schema.

I found 2 formats to do this on the Internet:

1. Using "#id" for the schema location - This format is supported by XSV (XML Schema Validator):

<?xml version="1.0"?>
<class xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 <xs:schema id="mySchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="class" type="xs:any"/>
   <xs:element name="student" type="xs:string"/>
 <student>Herong Yang</student>
 <student>John Smith</student>

2: Using no schema location attribute - This format is supported by .NET Framework:

<?xml version="1.0"?>
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="student" type="xs:string"/>
  <student>Herong Yang</student>
  <student>John Smith</student>

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


 Full Version in PDF/EPUB