@openui5/sap.ui.core
Version:
OpenUI5 Core Library sap.ui.core
123 lines (115 loc) • 3.57 kB
JavaScript
/*!
* OpenUI5
* (c) Copyright 2009-2023 SAP SE or an SAP affiliate company.
* Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
*/
// Provides xml parsing and error checking functionality.
sap.ui.define([
'jquery.sap.global',
'sap/ui/util/XMLHelper'
], function(jQuery, XMLHelper) {
"use strict";
/**
* Parses the specified XML formatted string text using native parsing
* function of the browser and returns a valid XML document. If an error
* occurred during parsing a parse error object is returned as property (parseError) of the
* returned XML document object. The parse error object has the following error
* information parameters: errorCode, url, reason, srcText, line, linepos, filepos
*
* @param {string}
* sXMLText the XML data as string
* @return {object} the parsed XML document with a parseError property as described in
* getParseError. An error occurred if the errorCode property of the parseError is != 0.
* @public
* @function
* @deprecated since 1.58 use {@link module:sap/ui/util/XMLHelper.parse} instead
*/
jQuery.sap.parseXML = XMLHelper.parse;
/**
* Serializes the specified XML document into a string representation.
*
* @param {string}
* oXMLDocument the XML document object to be serialized as string
* @return {object} the serialized XML string
* @public
* @deprecated since 1.58 use {@link module:sap/ui/util/XMLHelper.serialize} instead
*/
jQuery.sap.serializeXML = function(oXMLDocument) {
var sXMLString = "";
if (window.ActiveXObject) {
sXMLString = oXMLDocument.xml;
if (sXMLString) {
return sXMLString;
}
}
if (window.XMLSerializer) {
return XMLHelper.serialize(oXMLDocument);
}
return sXMLString;
};
/**
* @deprecated since 1.58 use native <code>Node#isEqualNode</code> instead
*/
jQuery.sap.isEqualNode = function(oNode1, oNode2) {
if (oNode1 === oNode2) {
return true;
}
if (!oNode1 || !oNode2) {
return false;
}
if (oNode1.isEqualNode) {
return oNode1.isEqualNode(oNode2);
}
if (oNode1.nodeType != oNode2.nodeType) {
return false;
}
if (oNode1.nodeValue != oNode2.nodeValue) {
return false;
}
if (oNode1.baseName != oNode2.baseName) {
return false;
}
if (oNode1.nodeName != oNode2.nodeName) {
return false;
}
if (oNode1.nameSpaceURI != oNode2.nameSpaceURI) {
return false;
}
if (oNode1.prefix != oNode2.prefix) {
return false;
}
if (oNode1.nodeType != 1) {
return true; //ELEMENT_NODE
}
if (oNode1.attributes.length != oNode2.attributes.length) {
return false;
}
for (var i = 0; i < oNode1.attributes.length; i++) {
if (!jQuery.sap.isEqualNode(oNode1.attributes[i], oNode2.attributes[i])) {
return false;
}
}
if (oNode1.childNodes.length != oNode2.childNodes.length) {
return false;
}
for (var i = 0; i < oNode1.childNodes.length; i++) {
if (!jQuery.sap.isEqualNode(oNode1.childNodes[i], oNode2.childNodes[i])) {
return false;
}
}
return true;
};
/**
* Extracts parse error information from the specified document (if any). If
* an error was found the returned object has the following error
* information parameters: errorCode, url, reason, srcText, line, linepos,
* filepos
*
* @return oParseError if errors were found, or an object with an errorCode of 0 only
* @private
* @function
* @deprecated since 1.58 use {@link module:sap/ui/util/XMLHelper.getParseError} instead
*/
jQuery.sap.getParseError = XMLHelper.getParseError;
return jQuery;
});