Last modified: 2013-04-08 11:02:25 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T26781, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24781 - define XML namespace for output of web API
define XML namespace for output of web API
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
1.17.x
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Roan Kattouw
: easy
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-13 14:33 UTC by Daniel Kinzler
Modified: 2013-04-08 11:02 UTC (History)
12 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Kinzler 2010-08-13 14:33:50 UTC
It would be useful to define an XML namespace for any XML-Formatted output of the web API. This would allow us to embed elements from that output in other XML documents easily. My own use case is embedding <rc> tags in XMPP stanzas.

I would suggest to use the URI http://www.mediawiki.org/xml/api-0.1 for the namespace. In practice, this would mean that the top level <api> tag returned by the API would become:

<api xmlns="http://www.mediawiki.org/xml/api-0.1">

This should have no impact whatsoever on backward compatibility, except perhaps for clients processing the XML using naive regular expressions. I believe it would be ok to break those, since they rely on things that are never guaranteed in XML.
Comment 1 Sam Reed (reedy) 2010-08-13 15:35:38 UTC
I agree on the breakage - It's not as if we're breaking conformity to valid xml etc.

IIRC (NB, I've not done much with this), we don't need to have anything served at that URL do we, it's just like an identifier?
Comment 2 Roan Kattouw 2010-08-13 15:37:25 UTC
Would anything need to be present at that URL? It currently 404s. If it needs like a full schema of possible outputs, that's a problem.
Comment 3 Daniel Kinzler 2010-08-13 15:43:08 UTC
no, namespaces are pure URIs. nothing needs to be there. Namespaces also don't require any schema or dtd.

it's useful to have some kind of documentation at that location though.
Comment 4 Sam Reed (reedy) 2010-08-13 17:49:58 UTC
http://www.mediawiki.org/wiki/api would be the easiest to have documentation there ;)
Comment 5 Bawolff (Brian Wolff) 2010-08-13 20:35:32 UTC
>This should have no impact whatsoever on backward compatibility

If you're using a namespace aware xml parser to parse the api, this could break it if your code expects the api output to have no namespace, and now it suddenly does.
Comment 6 Daniel Kinzler 2010-08-13 20:48:17 UTC
at #5: how would the code expect that? In what way would one usually rely on the fact that no namespace is used? And if so, why use a namespace aware parser?

I understand the point in theory, but can't imagine when it would actually happen.
Comment 7 Bawolff (Brian Wolff) 2010-08-13 20:50:18 UTC
It is still rather far fetched, I just thought I should mention it because it seemed more likely breakage case than the regex one.
Comment 8 Sam Reed (reedy) 2011-01-03 23:34:07 UTC
Bringing some life back here.

The fix is fairly simple, and there are possibly some breakages. I'm almost inclined to just say "tough" to those not doing it properly

Thoughts?
Comment 9 Ilmari Karonen 2011-01-03 23:46:01 UTC
Although I would defer to those more familiar with all things XMLish, I'm inclined to agree with Reedy here.  Anything that breaks because of a change like this was really already broken.  (Of course, having said that, I bet my own API clients are going to choke on it... :)
Comment 10 Roan Kattouw 2011-05-13 14:33:55 UTC
Daniel poked me about this at the hackathon, gonna start doing this in a minute.
Comment 11 Roan Kattouw 2011-05-13 16:35:08 UTC
Fixed in r88007. I used http://www.mediawiki.org/xml/api/ as a namespace and created that URL on the cluster as well.
Comment 12 Ariel T. Glenn 2011-10-06 12:06:34 UTC
Not completely breakage-proof, it seems:  see the comment about XPATH  at http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88007#c23862  reported by a user of the jdom library.
Comment 13 Svick 2011-10-06 12:17:27 UTC
Just a note, this really is a breaking change for some parsers. Specifically, for the one I'm using: LINQ to XML in .Net. It is namespace-aware and when a namespace is present, it has to be always used.

For example to get the root node, previously you would do:

var elem = document.Element("api");

With the namespace, the previous code wouldn't work and would have to be changed to:

XNamespace ns = "http://www.mediawiki.org/xml/api/";
var elem = document.Element(ns + "api");

I'm not arguing against the change (I think it's a good idea), but I wanted to let you know that it's going to be a breaking change, at least for some people.
Comment 14 Bryan Tong Minh 2011-10-06 19:48:14 UTC
Since this apparently is a breaking change, can we revert it and make the addition of a namespace optional, perhaps with the boolean includexmlnamespace?
Comment 15 Roan Kattouw 2011-10-06 19:55:44 UTC
(In reply to comment #14)
> Since this apparently is a breaking change, can we revert it and make the
> addition of a namespace optional, perhaps with the boolean includexmlnamespace?
Sounds good. Mind doing this yourself? I'm busy packing now and will be traveling for the next few days.
Comment 16 Bryan Tong Minh 2011-10-06 20:16:09 UTC
r99135
Comment 17 Roan Kattouw 2011-10-06 20:44:57 UTC
(In reply to comment #16)
> r99135
Deployed.
Comment 18 Rob Lanphier 2011-10-06 22:18:35 UTC
This would make me sad if this is a permanent option, since this is option bloat.  LINQ to XML in .Net is presenting a really broken API if it's requiring the caller provide the namespace URI to parse the resulting XML.  Not the end of the world if we have to leave it in there, but wow that's sad.
Comment 19 Roan Kattouw 2011-10-06 22:19:47 UTC
(In reply to comment #18)
> This would make me sad if this is a permanent option, since this is option
> bloat.  LINQ to XML in .Net is presenting a really broken API if it's requiring
> the caller provide the namespace URI to parse the resulting XML.  Not the end
> of the world if we have to leave it in there, but wow that's sad.
If you think this is sad, you ain't seen nothin' yet ;)
Comment 20 shubinator1 2011-10-07 06:44:58 UTC
For the record:
Many XML parsers, including (as noted) JDOM and MSXML (on top of which the .NET XML library, among many other libraries, is built) are namespace-aware. This isn't "not doing it properly", it's arguably doing it properly, since two XML nodes that only differ in which namespace they belong to should be treated as different node types.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links