Localisation updates from http://translatewiki.net.
[mediawiki.git] / resources / jquery / jquery.xmldom.js
blob85d0083d22ed28fa9dbda1b2ea7e247f85a01206
1 /*!
2  * jQuery xmlDOM Plugin v1.0
3  * http://outwestmedia.com/jquery-plugins/xmldom/
4  *
5  * Released: 2009-04-06
6  * Version: 1.0
7  *
8  * Copyright (c) 2009 Jonathan Sharp, Out West Media LLC.
9  * Dual licensed under the MIT and GPL licenses.
10  * http://docs.jquery.com/License
11  */
12 (function($) {
13         // IE DOMParser wrapper
14         if ( window['DOMParser'] == undefined && window.ActiveXObject ) {
15                 DOMParser = function() { };
16                 DOMParser.prototype.parseFromString = function( xmlString ) {
17                         var doc = new ActiveXObject('Microsoft.XMLDOM');
18                 doc.async = 'false';
19                 doc.loadXML( xmlString );
20                         return doc;
21                 };
22         }
23         
24         $.xmlDOM = function(xml, onErrorFn) {
25                 try {
26                         var xmlDoc      = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
27                         if ( $.isXMLDoc( xmlDoc ) ) {
28                                 var err = $('parsererror', xmlDoc);
29                                 if ( err.length == 1 ) {
30                                         throw('Error: ' + $(xmlDoc).text() );
31                                 }
32                         } else {
33                                 throw('Unable to parse XML');
34                         }
35                 } catch( e ) {
36                         var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
37                         if ( $.isFunction( onErrorFn ) ) {
38                                 onErrorFn( msg );
39                         } else {
40                                 $(document).trigger('xmlParseError', [ msg ]);
41                         }
42                         return $([]);
43                 }
44                 return $( xmlDoc );
45         };
46 })(jQuery);