<head> <title>Schematron sample</title> </head> <?php include_once "class_schematron.php"; print "<h1>Schematron Test</h1>"; $s = new Schematron(); $s->compile_schematron_from_file("validation_sample1.xml"); $compiled = $s->get_compiled("validation_sample1.xml"); $s->save_compiled("validation_sample1.xml", "validation1.xsl"); $fp = fopen("validation_sample1.xml", "r"); $uncompiled = fread($fp, filesize("validation_sample1.xml")); fclose($fp); $fp = fopen("sample1.xml", "r"); $xml = fread($fp, filesize("sample1.xml")); fclose($fp); /* Uncompiled tests */ print "<h3>Testing Schematron for uncompiled scripts</h3>"; /* FILE USING FILE */ $ret = $s->schematron_validate_file_using_file("sample1.xml", "validation_sample1.xml"); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* FILE USING MEM */ $ret = $s->schematron_validate_file_using_mem("sample1.xml", $uncompiled); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* MEM USING FILE */ $ret = $s->schematron_validate_mem_using_file($xml, "validation_sample1.xml"); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* MEM USING MEM */ $ret = $s->schematron_validate_mem_using_mem($xml, $uncompiled); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /**** COMPILED SCRIPTS **/
/* creating a DomDocument object */ $objDom = new DomDocument(); /* loading the xml data */ $objDom->loadXML($xmlFileFinal); /* tries to validade your data */ if (!$objDom->schemaValidate("../../../../XML/schemas/ARBuilder0_1.xsd")) { /* if anything goes wrong you can get all errors at once */ $allErrors = libxml_get_errors(); /* each element of the array $allErrors will be a LibXmlError Object */ print_r($allErrors); print "<h2>Validation was incorrect</h2>"; } else { print "<h2>Validation was finished correctly</h2>"; } require_once "../../../../sources/models/Schematron.php"; $s = new Schematron(); //$fp=fopen("validation_sample1.xml","r"); $fp = fopen("ARQuery_check.sch", "r"); $uncompiled = fread($fp, filesize("ARQuery_check.sch")); fclose($fp); //$fp=fopen("sample1.xml","r"); //$fp = fopen("ARQuery-Sample.xml", "r"); //$xml = fread($fp, filesize("ARQuery-Sample.xml")); //fclose($fp); /* Uncompiled tests */ print "<h3>Schematron Test</h3>"; /* MEM USING MEM */ $ret = $s->schematronValidate($xmlFileFinal, $uncompiled); print "<textarea rows='10' cols='100'>{$ret}</textarea>"; $filePath = "ARQuery-Sample.xml"; $file = fopen($filePath, "r");
<head> <title>Schematron sample</title> </head> <?php include "../../lib/Schematron.php"; print "<h1>Schematron Test</h1>"; $s = new Schematron(); $fp = fopen("validation_sample1.xml", "r"); $uncompiled = fread($fp, filesize("validation_sample1.xml")); fclose($fp); $fp = fopen("sample1.xml", "r"); $xml = fread($fp, filesize("sample1.xml")); fclose($fp); /* Uncompiled tests */ print "<h3>Testing Schematron for uncompiled scripts</h3>"; /* FILE USING FILE */ $ret = $s->schematron_validate_file_using_file("sample1.xml", "validation_sample1.xml"); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* FILE USING MEM */ $ret = $s->schematron_validate_file_using_mem("sample1.xml", $uncompiled); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* MEM USING FILE */ $ret = $s->schematron_validate_mem_using_file($xml, "validation_sample1.xml"); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* MEM USING MEM */ $ret = $s->schematron_validate_mem_using_mem($xml, $uncompiled); print "<textarea rows='10' cols='20'>{$ret}</textarea>"; /* * ** COMPILED SCRIPTS * */ print "<h3>Now testing for compiled scripts</h3>"; /* FILE USING FILE */ $ret = $s->schematron_validate_file_using_compiled_file("sample1.xml", "validation1.xsl");