XML Tutorials - Herong's Tutorial Examples - v5.25, by Herong Yang
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
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