public function testExportDemo()
 {
     $fname = "../../docs/export-demo.xml";
     $version = WikiExporter::schemaVersion();
     $dom = new DomDocument();
     $dom->load($fname);
     // Ensure, the demo is for the current version
     $this->assertEquals($dom->documentElement->getAttribute('version'), $version, 'export-demo.xml should have the current version');
     $this->assertTrue($dom->schemaValidate("../../docs/export-" . $version . ".xsd"), "schemaValidate has found an error");
 }
 /**
  * Validates a xml file against the xsd.
  *
  * The validation is slow, because php has to read the xsd on each call.
  *
  * @param $fname string: name of file to validate
  */
 protected function validateXmlFileAgainstXsd($fname)
 {
     $version = WikiExporter::schemaVersion();
     $dom = new DomDocument();
     $dom->load($fname);
     try {
         $this->assertTrue($dom->schemaValidate("../../docs/export-" . $version . ".xsd"), "schemaValidate has found an error");
     } catch (Exception $e) {
         $this->fail("xml not valid against xsd: " . $e->getMessage());
     }
 }
Example #3
0
 /**
  * Validates a xml file against the xsd.
  *
  * The validation is slow, because php has to read the xsd on each call.
  *
  * @param $fname string: name of file to validate
  */
 protected function validateXmlFileAgainstXsd($fname)
 {
     $version = WikiExporter::schemaVersion();
     $dom = new DomDocument();
     $dom->load($fname);
     // Ensure, the demo is for the current version
     $this->assertEquals($dom->documentElement->getAttribute('version'), $version, 'export-demo.xml should have the current version');
     try {
         $this->assertTrue($dom->schemaValidate("../../docs/export-" . $version . ".xsd"), "schemaValidate has found an error");
     } catch (Exception $e) {
         $this->fail("xml not valid against xsd: " . $e->getMessage());
     }
 }
 /**
  * Opens the XML output stream's root "<mediawiki>" element.
  * This does not include an xml directive, so is safe to include
  * as a subelement in a larger XML stream. Namespace and XML Schema
  * references are included.
  *
  * Output will be encoded in UTF-8.
  *
  * @return string
  */
 function openStream()
 {
     global $wgLanguageCode;
     $ver = WikiExporter::schemaVersion();
     return Xml::element('mediawiki', array('xmlns' => "http://www.mediawiki.org/xml/export-{$ver}/", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-{$ver}/ " . "http://www.mediawiki.org/xml/export-{$ver}.xsd", 'version' => $ver, 'xml:lang' => $wgLanguageCode), null) . "\n" . $this->siteInfo();
 }