XML Tutorials - Herong's Tutorial Examples - Version 5.05, by Dr. 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>
Last update: 2014.
Table of Contents