Local XML validation using DTD or XSD using relative path?

An XML file can be defined and validated using Document Type Description (DTD) or XML Schema (xsd) as follows:

<?xml version='1.0' encoding='UTF-8'?> <annotation xmlns="http://www.xyz.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyz.com file:system.xsd" > 

or

 <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE annotation SYSTEM "http://www.xyz.de/system.dtd"> 

Both methods specify the URL where a DTD or XSD is detected. Is there a way to give a relative or local path? So can I store them with XML files instead of relying on the server?

+4
source share
1 answer

It is easy. Just put the relative location of the file like

 <?xml version='1.0' encoding='UTF-8'?> <annotation xmlns="http://www.xyz.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyz.com ./system.xsd" > 
+11
source

All Articles