How to define schematron in XML file for validation?

I am new to XML stuff. The answer would be simple, but I'm struggling for a couple of days. Of course it was completely on stackoverflow to get the solution, but I don't know if I have sufficient knowledge in XML to get it or understand it. So, finally, to get a solution from the experts.

Well I have an xml file, a DTD and a sch file. I am using eclipse to validate xml against DTD. But I don't know how to check the xml for sch file.

Sample XML file

<?xml version="1.0" encoding="UTF-8"?>
  PUBLIC "-//SAGE//DTD SAGE Hub XML DTD v1.0 20111101/EN" "SAGE-hubxml.dtd">
<SAGE-hubxml xmlns="" xmlns:xi=""
    xmlns:svg="" xmlns:xlink="">


In this I have defined the DTD file to check. I don't know how to define the sch file to check. What's the easiest way to do this? And I would use php to validate xml against DTD.


$dom = new DOMDocument;
if ($dom->validate()) {
    echo "This document is valid!\n";
echo "This document is not  valid!";


So if we can check xml against sch using php it would be very helpful


In some documentation they mentioned an xml editor to check the sch file. I need something else like oxygen is a commercial tool. /home/srini/Pictures/Selection_003.png


source to share

1 answer

I don't think you can define a schema file like XML Schema (or DTD) and validate it in the same way.

You have to use php schematron library than handle sch files, or convert sch files to XSLT files and then XLST processor to validate the XML file.



All Articles