C_XmlPrettyPrinter.js 4.1 KB

123456
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: hal
  3. // (C) Copyright IBM Corp. 2003, 2017.
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. function C_XmlPrettyPrinter(n){this._h6B2=n;};C_XmlPrettyPrinter.prototype.F_ToString=function(){this._hH11=new C_StringStream();if(this._h6B2.nodeType==U_XML.K_iNODE_DOCUMENT){this._h1S1(this._h6B2.documentElement, 0);}else{this._h1S1(this._h6B2, 0);}return this._hH11.F_ToString();};C_XmlPrettyPrinter.prototype._h1S1=function(n,_hTX1){var _hUX1=n.nodeName;var _hQL=n.selectNodes("*").length;if(n==n.ownerDocument.documentElement&&n.ownerDocument.doctype){this._hH11.F_Write("<div class='clsPrettyPrintDocType'>");this._hH11.F_Write(n.ownerDocument.doctype.xml.F_HTMLEncode());this._hH11.F_Write("</div>");}var _hVX1="padding-left:" + _hTX1 + "px;";if(_hQL>0){var _hWX1=U_DOM.F_GetUniqueId();this._hH11.F_Write("<div style='cursor: pointer;");this._hH11.F_Write(_hVX1);this._hH11.F_Write( "' onclick='F_CollapseNode(this)' childId='" );this._hH11.F_Write(_hWX1);this._hH11.F_Write("'><span class='clsPrettyPrintExpandLink'>- </span>");}else{this._hH11.F_Write("<div style='");this._hH11.F_Write(_hVX1);this._hH11.F_Write("'><span style='visibility:hidden' class='clsPrettyPrintExpandLink'>- </span>");}this._hH11.F_Write( "<span class='clsPrettyPrintBrackets'>&lt;</span>" );this._hH11.F_Write("<span class='clsPrettyPrintNodeName'>");this._hH11.F_Write(_hUX1.F_HTMLEncode());this._hH11.F_Write("</span>");var nl=n.attributes;var _hBZ1=nl.length;for(var i=0;i<_hBZ1;i++){var _hL92=nl.item(i);var _hNG1=_hL92.name;var _h552=_hL92.value;if(!U_XML.F_IsAttributeSpecified(n, _hL92)){continue;}var _hMV="clsPrettyPrintAttribute";var _h2Q="clsPrettyPrintNodeText";if(_hNG1.slice(0, 5)=="xmlns"){_hMV="clsPrettyPrintNamespaceDecl";_h2Q="clsPrettyPrintNamespaceURI";}this._hH11.F_Write( "<span class='" );this._hH11.F_Write(_hMV);this._hH11.F_Write( "'> " );this._hH11.F_Write(_hNG1.F_HTMLEncode());this._hH11.F_Write( '</span><span class="clsPrettyPrintBrackets">="</span><span class="' );this._hH11.F_Write(_h2Q);this._hH11.F_Write('">');this._hH11.F_Write(_h552.F_HTMLEncode());this._hH11.F_Write( '</span><span class="clsPrettyPrintBrackets">"</span>' );}var nl=n.selectNodes( "* | text() | comment()" );var _hBZ1=nl.length;var _hHE1=(_hBZ1>0)?"&gt;":"/&gt;";this._hH11.F_Write( "<span class='clsPrettyPrintBrackets'>" );this._hH11.F_Write(_hHE1);this._hH11.F_Write("</span>");if(_hQL>0){this._hH11.F_Write("</div><div id=");this._hH11.F_Write(_hWX1);this._hH11.F_Write(" expandedState='expanded'>");}_hTX1=_hTX1+20;for(var i=0;i<_hBZ1;i++){var _hP72=nl.item(i);switch(_hP72.nodeType){case U_XML.K_iNODE_TEXT:this._hH11.F_Write( "<span class='clsPrettyPrintNodeText'>" );this._hH11.F_Write(_hP72.nodeValue.F_HTMLEncode());this._hH11.F_Write("</span>");break;case U_XML.K_iNODE_COMMENT:this._hH11.F_Write("<span>&lt;!--");this._hH11.F_Write(_hP72.nodeValue.F_HTMLEncode());this._hH11.F_Write("--&gt;</span>");break;case U_XML.K_iNODE_CDATA_SECTION:this._hH11.F_Write("<span>&lt;![CDATA[");this._hH11.F_Write(_hP72.nodeValue.F_HTMLEncode());this._hH11.F_Write("]]&gt;</span>");break;default:this._h1S1(_hP72, _hTX1);}}if(_hBZ1>0){_hVX1=_hQL>0?_hVX1:"";var _h932=_hQL>0?"<span style='visibility:hidden'>- </span>":"";this._hH11.F_Write(_h932);this._hH11.F_Write( "<span class='clsPrettyPrintBrackets' style='" );this._hH11.F_Write(_hVX1);this._hH11.F_Write( "'>&lt;/</span><span class='clsPrettyPrintNodeName'>" );this._hH11.F_Write(n.nodeName.F_HTMLEncode());this._hH11.F_Write( "</span><span class='clsPrettyPrintBrackets'>&gt;</span>" );}this._hH11.F_Write("</div>");};function F_CollapseNode(_h2S1){var _hIE1=_h2S1;if(_hIE1.getAttribute("childId")){var _hLZ1=_h2S1.ownerDocument.getElementById(_hIE1.getAttribute("childId"));var _h3S1=_hLZ1.getAttribute("expandedState");if(_h3S1=="expanded"){_hLZ1.style.display="none";_hIE1.firstChild.innerHTML= "+ ";_hLZ1.setAttribute("expandedState", "collapsed");}else{_hLZ1.style.display="";_hIE1.firstChild.innerHTML="- ";_hLZ1.setAttribute("expandedState", "expanded");}}};