r88007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88006‎ | r88007 | r88008 >
Date:16:34, 13 May 2011
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 24781) Define XML namespace for API output. Also created the referenced URL on the cluster.
Modified paths:
  • /trunk/phase3/includes/api/ApiFormatXml.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiFormatXml.php
@@ -36,6 +36,7 @@
3737 class ApiFormatXml extends ApiFormatBase {
3838
3939 private $mRootElemName = 'api';
 40+ public static $namespace = 'http://www.mediawiki.org/xml/api/';
4041 private $mDoubleQuote = false;
4142 private $mXslt = null;
4243
@@ -66,7 +67,7 @@
6768 }
6869 $this->printText(
6970 self::recXmlPrint( $this->mRootElemName,
70 - $this->getResultData(),
 71+ array( 'xmlns' => self::$namespace ) + $this->getResultData(),
7172 $this->getIsHtml() ? - 2 : null,
7273 $this->mDoubleQuote
7374 )

Sign-offs

UserFlagDate
Brion VIBBERinspected16:39, 13 May 2011
Brion VIBBERtested16:39, 13 May 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r99135(bug 24781) The API will include an XML namespace if the includexmlnamespace ...btongminh20:11, 6 October 2011
r99415MFT r99135 -- partially undoes breakage from r88007...brion18:34, 10 October 2011
r101912* (bug 31878, bug 31542) Fix XML namespace output in API; removed now-unneede...brion23:14, 3 November 2011

Comments

#Comment by Reedy (talk | contribs)   21:35, 13 May 2011

Probably worth doing a mailing list post to go with this, as if per the bug, if people are using crappy code, and parsing XML with regex, it could be a "breaking change" for them, even though it's within the XML specification

#Comment by Merlissimo (talk | contribs)   11:08, 6 October 2011

This is a breaking change if you are using XPATH. An unprefixed QName uses the "default element namespace" by definition. This is set to none if not specified in xpath (http://www.w3.org/TR/xpath20/#dt-def-elemtype-ns ). So after this change you have to add this namespace definition to xpath to match this element or its children of an xml document.

Status & tagging log