From bc2aa6314a8d82854a799fe1e750c05dcef1b492 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 23 May 2011 06:31:39 +0000 Subject: Some Javascript cleanup, now working across all browsers including IE9. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1126329 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/js/htdocs/xmlutil.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'sca-cpp/trunk/modules/js/htdocs/xmlutil.js') diff --git a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js index 3965596599..4d943cce75 100644 --- a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js @@ -111,19 +111,8 @@ function isXML(l) { */ function parseXML(l) { var s = writeStrings(l); - if (window.DOMParser) { - var p = new DOMParser(); - return p.parseFromString(s, "text/xml"); - } - var doc; - try { - doc = new ActiveXObject("MSXML2.DOMDocument"); - } catch (e) { - doc = new ActiveXObject("Microsoft.XMLDOM"); - } - doc.async = 'false'; - doc.loadXML(s); - return doc; + var p = new DOMParser(); + return p.parseFromString(s, "text/xml"); } /** @@ -196,7 +185,12 @@ function writeList(l, node, doc) { var token = car(l); if (isTaggedList(token, attribute)) { - node.setAttribute(attributeName(token).substring(1), '' + attributeValue(token)); + if (isIE()) { + var aname = attributeName(token).substring(1); + if (aname != 'xmlns') + node.setAttribute(aname, '' + attributeValue(token)); + } else + node.setAttribute(attributeName(token).substring(1), '' + attributeValue(token)); } else if (isTaggedList(token, element)) { @@ -213,7 +207,9 @@ function writeList(l, node, doc) { } var ns = xmlns(elementChildren(tok)); - if (ns == null || !doc.createElementNS) + if (isIE()) + return doc.createElementNS(ns != null? ns : node.namespaceURI, elementName(tok).substring(1)); + if (ns == null) return doc.createElement(elementName(tok).substring(1)); return doc.createElementNS(ns, elementName(tok).substring(1)); } @@ -244,9 +240,7 @@ function writeList(l, node, doc) { * Make a new XML document. */ function mkXMLDocument() { - if (document.implementation && document.implementation.createDocument) - return document.implementation.createDocument('', '', null); - return new ActiveXObject("MSXML2.DOMDocument"); + return document.implementation.createDocument('', '', null); } /** -- cgit v1.2.3