(bug 22750) <logitem> is at wrong location in export.xsd
authorumherirrender <umherirrender_de.wp@web.de>
Fri, 1 Jun 2012 15:57:02 +0000 (17:57 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Fri, 1 Jun 2012 15:57:02 +0000 (17:57 +0200)
* fix indent of logitem
* add logtitle/params tags
* change one Image: to File:

Change-Id: I02e631d8c4679c46095320901cdff724533d66f0

docs/export-0.7.xsd
includes/Export.php

index c2656a3..2d64036 100644 (file)
@@ -21,6 +21,7 @@
        Version 0.7 adds a unique identity constraint for both page and
        revision identifiers. See also bug 4220.
        Fix type for <ns> from "positiveInteger" to "nonNegativeInteger" to allow 0
+       Moves <logitem> to its right location.
 
        The canonical URL to the schema document is:
        http://www.mediawiki.org/xml/export-0.7.xsd
@@ -63,6 +64,8 @@
                                         minOccurs="0" maxOccurs="1"/>
                        <element name="page" type="mw:PageType"
                                         minOccurs="0" maxOccurs="unbounded"/>
+                       <element name="logitem" type="mw:LogItemType"
+                                        minOccurs="0" maxOccurs="unbounded"/>
                </sequence>
                <attribute name="version" type="string" use="required"/>
                <attribute ref="xml:lang" use="required"/>
                        <choice minOccurs="0" maxOccurs="unbounded">
                                <element name="revision" type="mw:RevisionType" />
                                <element name="upload" type="mw:UploadType" />
-                               <element name="logitem" type="mw:LogItemType" />
                        </choice>
 
                        <!-- Zero or One sets of discussion threading data -->
                        <element name="comment" type="mw:CommentType" minOccurs="0"/>
                        <element name="type" type="string" />
                        <element name="action" type="string" />
-                       <element name="text" type="mw:TextType" />
+                       <element name="text" type="mw:LogTextType" minOccurs="0" maxOccurs="1" />
+                       <element name="logtitle" type="string" minOccurs="0" maxOccurs="1" />
+                       <element name="params" type="mw:LogParamsType" minOccurs="0" maxOccurs="1" />
                </sequence>
        </complexType>
 
                </simpleContent>
        </complexType>
 
+       <complexType name="LogTextType">
+               <simpleContent>
+                       <extension base="string">
+                               <!-- This allows deleted=deleted on non-empty elements, but XSD is not omnipotent -->
+                               <attribute name="deleted" use="optional" type="mw:DeletedFlagType"/>
+                       </extension>
+               </simpleContent>
+       </complexType>
+
+       <complexType name="LogParamsType">
+               <simpleContent>
+                       <extension base="string">
+                               <attribute ref="xml:space" use="optional" default="preserve" />
+                       </extension>
+               </simpleContent>
+       </complexType>
+
        <complexType name="ContributorType">
                <sequence>
                        <element name="username" type="string" minOccurs="0"/>
                        <element name="contributor" type="mw:ContributorType"/>
                        <element name="comment" type="string" minOccurs="0"/>
 
-                       <!-- Filename. (Using underscores, not spaces. No 'Image:' namespace marker.) -->
+                       <!-- Filename. (Using underscores, not spaces. No 'File:' namespace marker.) -->
                        <element name="filename" type="string"/>
 
                        <!-- URI at which this resource can be obtained -->
index c201c97..c73824d 100644 (file)
@@ -685,37 +685,37 @@ class XmlDumpWriter {
        function writeLogItem( $row ) {
                wfProfileIn( __METHOD__ );
 
-               $out  = "    <logitem>\n";
-               $out .= "      " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
+               $out  = "  <logitem>\n";
+               $out .= "    " . Xml::element( 'id', null, strval( $row->log_id ) ) . "\n";
 
-               $out .= $this->writeTimestamp( $row->log_timestamp );
+               $out .= $this->writeTimestamp( $row->log_timestamp, "    " );
 
                if ( $row->log_deleted & LogPage::DELETED_USER ) {
-                       $out .= "      " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
+                       $out .= "    " . Xml::element( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n";
                } else {
-                       $out .= $this->writeContributor( $row->log_user, $row->user_name );
+                       $out .= $this->writeContributor( $row->log_user, $row->user_name, "    " );
                }
 
                if ( $row->log_deleted & LogPage::DELETED_COMMENT ) {
-                       $out .= "      " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
+                       $out .= "    " . Xml::element( 'comment', array( 'deleted' => 'deleted' ) ) . "\n";
                } elseif ( $row->log_comment != '' ) {
-                       $out .= "      " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
+                       $out .= "    " . Xml::elementClean( 'comment', null, strval( $row->log_comment ) ) . "\n";
                }
 
-               $out .= "      " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
-               $out .= "      " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
+               $out .= "    " . Xml::element( 'type', null, strval( $row->log_type ) ) . "\n";
+               $out .= "    " . Xml::element( 'action', null, strval( $row->log_action ) ) . "\n";
 
                if ( $row->log_deleted & LogPage::DELETED_ACTION ) {
-                       $out .= "      " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
+                       $out .= "    " . Xml::element( 'text', array( 'deleted' => 'deleted' ) ) . "\n";
                } else {
                        $title = Title::makeTitle( $row->log_namespace, $row->log_title );
-                       $out .= "      " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n";
-                       $out .= "      " . Xml::elementClean( 'params',
+                       $out .= "    " . Xml::elementClean( 'logtitle', null, self::canonicalTitle( $title ) ) . "\n";
+                       $out .= "    " . Xml::elementClean( 'params',
                                array( 'xml:space' => 'preserve' ),
                                strval( $row->log_params ) ) . "\n";
                }
 
-               $out .= "    </logitem>\n";
+               $out .= "  </logitem>\n";
 
                wfProfileOut( __METHOD__ );
                return $out;
@@ -725,9 +725,9 @@ class XmlDumpWriter {
         * @param $timestamp string
         * @return string
         */
-       function writeTimestamp( $timestamp ) {
+       function writeTimestamp( $timestamp, $indent = "      " ) {
                $ts = wfTimestamp( TS_ISO_8601, $timestamp );
-               return "      " . Xml::element( 'timestamp', null, $ts ) . "\n";
+               return $indent . Xml::element( 'timestamp', null, $ts ) . "\n";
        }
 
        /**
@@ -735,15 +735,15 @@ class XmlDumpWriter {
         * @param $text string
         * @return string
         */
-       function writeContributor( $id, $text ) {
-               $out = "      <contributor>\n";
+       function writeContributor( $id, $text, $indent = "      " ) {
+               $out = $indent . "<contributor>\n";
                if ( $id || !IP::isValid( $text ) ) {
-                       $out .= "        " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
-                       $out .= "        " . Xml::element( 'id', null, strval( $id ) ) . "\n";
+                       $out .= $indent . "  " . Xml::elementClean( 'username', null, strval( $text ) ) . "\n";
+                       $out .= $indent . "  " . Xml::element( 'id', null, strval( $id ) ) . "\n";
                } else {
-                       $out .= "        " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
+                       $out .= $indent . "  " . Xml::elementClean( 'ip', null, strval( $text ) ) . "\n";
                }
-               $out .= "      </contributor>\n";
+               $out .= $indent . "</contributor>\n";
                return $out;
        }