~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/datatype-xml-parse/datatype-xml-parse.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('datatype-xml-parse', function(Y) {
 
8
 
 
9
/**
 
10
 * Parse XML submodule.
 
11
 *
 
12
 * @module datatype
 
13
 * @submodule datatype-xml-parse
 
14
 * @for DataType.XML
 
15
 */
 
16
 
 
17
var LANG = Y.Lang;
 
18
 
 
19
Y.mix(Y.namespace("DataType.XML"), {
 
20
    /**
 
21
     * Converts data to type XMLDocument.
 
22
     *
 
23
     * @method parse
 
24
     * @param data {String} Data to convert.
 
25
     * @return {XMLDoc} XML Document.
 
26
     */
 
27
    parse: function(data) {
 
28
        var xmlDoc = null;
 
29
        if(LANG.isString(data)) {
 
30
            try {
 
31
                if(!LANG.isUndefined(ActiveXObject)) {
 
32
                        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
 
33
                        xmlDoc.async = false;
 
34
                        xmlDoc.loadXML(data);
 
35
                }
 
36
            }
 
37
            catch(ee) {
 
38
                try {
 
39
                    if(!LANG.isUndefined(DOMParser)) {
 
40
                        xmlDoc = new DOMParser().parseFromString(data, "text/xml");
 
41
                    }
 
42
                }
 
43
                catch(e) {
 
44
                }
 
45
            }
 
46
        }
 
47
        
 
48
        if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
 
49
        }
 
50
        
 
51
        return xmlDoc;
 
52
    }
 
53
});
 
54
 
 
55
// Add Parsers shortcut
 
56
Y.namespace("Parsers").xml = Y.DataType.XML.parse;
 
57
 
 
58
 
 
59
 
 
60
}, '3.5.1' );