Search code examples
xmlxsdxsd-validationdtdxml-validation

Concurrent DTD & XSD validation in XML


Is it possible to validate XML document by DTD and XSD at the same time?

What I mean is, can the DTD & XSD validation code be inserted in the XML file?

Here is my code:

ns.xml

<?xml version="1.0" encoding="UTF-8" ?>
   
           //DTD//
<!DOCTYPE root SYSTEM "ns.dtd">

          //XSD//
<ss:root xmlns:ss="http://example.com/ns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://example.com/ns ns.xsd">
</ss:root>

Solution

  • Is it possible to validate XML document by DTD & XSD at the same time?

    Yes, of course an XML file can be validated against any number of schemas – DTDs, XSDs, Schematron, RELAX NG, etc.

    What I mean is, can the DTD and XSD validation code be inserted in the XML file?

    Unlike with DTDs, there is no standard way in which to embed XSDs within an XML file.

    See also