I'm newbie in XML stuffs. Answer would be simple but am struggling for couple of days. Ofcourse was fully in stackoverflow to get the solution but I don't know whether I have enough knowledge in XML to get it or understand it. So, finally am here to get the solution from experts.
Well, I have an xml file, DTD and sch file. Am using eclipse to validate an xml against DTD. But i don't know how to validate an xml against 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 DTD file to validate. I don't know how to define sch file to validate. What would be the simplest way to do it? And I would use php to validate an xml against DTD.
php
$dom = new DOMDocument;
$dom->Load('sample.xml');
if ($dom->validate()) {
echo "This document is valid!
";
}
else{
echo "This document is not valid!";
}
So, if we can validate xml against sch using php, would be greatly helpful
Updates
In some documentation, they have mentioned about oxygen xml editor,to validate against sch file. I need something else similar as oxygen is a commerical tool.
I don't think you can define a schematron file like a XML schema (or DTD) and validate it the same way.
You have to use a php schematron library than can process sch files, or transform the sch files into XSLT files, then an XLST processor to validate the XML file.