*/
var $sink;
+ /**
+ * Returns the export schema version.
+ * @return string
+ */
+ public static function schemaVersion() {
+ return "0.7";
+ }
+
/**
* If using WikiExporter::STREAM to stream a large amount of data,
* provide a database connection which is not managed by
class XmlDumpWriter {
/**
* Returns the export schema version.
+ * @deprecated in 1.20; use WikiExporter::schemaVersion() instead
* @return string
*/
function schemaVersion() {
- return "0.7";
+ wfDeprecated( __METHOD__, '1.20' );
+ return WikiExporter::schemaVersion();
}
/**
*/
function openStream() {
global $wgLanguageCode;
- $ver = $this->schemaVersion();
+ $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",
--- /dev/null
+<?php
+/**
+ * Test for the demo xml
+ *
+ * @group Dump
+ */
+class ExportDemoTest extends DumpTestCase {
+
+ /**
+ * @group large
+ */
+ function testExportDemo() {
+ $this->validateXmlFileAgainstXsd( "../../docs/export-demo.xml" );
+ }
+
+ /**
+ * 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() );
+ }
+ }
+}