XML Tutorials - Herong's Tutorial Examples - v5.25, by Herong Yang
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" xsi:noNamespaceSchemaLocation="#mySchema"> <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"/> </xs:schema> <student>Herong Yang</student> <student>John Smith</student> </class>
2: Using no schema location attribute - This format is supported by .NET Framework:
<?xml version="1.0"?> <class> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="student" type="xs:string"/> </xs:schema> <student>Herong Yang</student> <student>John Smith</student> </class>
Table of Contents
Introduction of XML (eXtensible Markup Language)
DOM (Document Object Model) Programming Interface
SAX (Simple API for XML) Programming Interface
DTD (Document Type Definition) Introduction
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
Validating XML Documents Against Specified XML Schemas
XSL (Extensible Stylesheet Language) Introduction
XSLT (XSL Transformations) Introduction
XSLT Elements as Programming Statements
Control and Generate XML Element in the Result
PHP Extensions for XML Manipulation
Processing XML with Python Scripts
XML Tools Plugin for Notepad++
XML Plugin Packages for Atom Editor