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"?>
<!DOCTYPE SAGE-hubxml
PUBLIC "-//SAGE//DTD SAGE Hub XML DTD v1.0 20111101/EN" "SAGE-hubxml.dtd">
<SAGE-hubxml xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<body>
</body>
</SAGE-hubxml>
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.
PHP
$dom = new DOMDocument;
$dom->Load('sample.xml');
if ($dom->validate()) {
echo "This document is valid!\n";
}
else{
echo "This document is not valid!";
}
So if we can check xml against sch using php it would be very helpful
Update
In some documentation they mentioned an xml editor to check the sch file. I need something else like oxygen is a commercial tool.
source to share