Changeset 3307
- Timestamp:
- 06/11/07 07:50:30 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/ominiverdi/openlayers/lib/OpenLayers/Control/WMSManager.js
r3262 r3307 942 942 var text = ajaxRequest.responseText; 943 943 944 var oDomDoc = Sarissa.getDomDocument();944 //var oDomDoc = Sarissa.getDomDocument(); 945 945 946 946 //myregexp = new RegExp('<!--[^(-->)]*-->'); … … 954 954 if(xml.childNodes.length==0) { 955 955 try{ 956 if( Sarissa.getParseErrorText(xml) == Sarissa.PARSED_OK){956 if(OpenLayers.Ajax.getParseErrorText(xml) == OpenLayers.Ajax.PARSED_OK){ 957 957 // The document was parsed/loaded just fine, go on 958 958 //alert(xml); … … 961 961 else{ 962 962 // The document was not loaded correctly! Inform the user: 963 var error = Sarissa.getParseErrorText(xml);963 var error = OpenLayers.Ajax.getParseErrorText(xml); 964 964 //alert(error); 965 965 var newwindow; 966 966 //Encode the xml inside the error message 967 encodedHtml = error;968 encodedHtml = encodedHtml.replace(/</g,"<");969 encodedHtml = encodedHtml.replace(/>/g,">");967 //encodedHtml = error; 968 //encodedHtml = encodedHtml.replace(/</g,"<"); 969 //encodedHtml = encodedHtml.replace(/>/g,">"); 970 970 //popup a message windows to let the use copy the error 971 971 newwindow=window.open('','','menubar=1,scrollbars=1,width=400,height=300,resizable=1') ; 972 972 //menubar=1,location=1,status=1, 973 973 newwindow.document.writeln('<html> <head> <title>Error Parsing GetCapabilties<\/title> <\/head> <body><pre><code>'); 974 newwindow.document.writeln( encodedHtml);974 newwindow.document.writeln(OpenLayers.Ajax.escape(error)); 975 975 newwindow.document.writeln('<\/code><\/pre> <\/body> <\/html>'); 976 976 newwindow.document.close(); … … 986 986 if(typeof xml=='object'){ 987 987 988 988 989 989 //Check exceptionsValue 990 990 var exceptions = xml.getElementsByTagName('Exception'); … … 996 996 for(i=0;i<aFormats.length;i++){ 997 997 //var format =(aFormats[i].textContent)? aFormats[i].textContent:aFormats[i].text; 998 var format = Sarissa.getText(aFormats[i]); 998 //var format = OpenLayers.Ajax.getText(aFormats[i]); 999 try{ 1000 var format = OpenLayers.Ajax.getText(aFormats[i]); 1001 } catch(e){alert(e)}; 999 1002 if(format ==exceptionsValue) formatExists = true; 1000 1003 else oFormats.push(format); … … 1003 1006 if(!formatExists) this.WMSManager.exceptionsValue = oFormats[0]; 1004 1007 } 1008 1005 1009 1006 1010 … … 1013 1017 for(i=0;i<aFormats.length;i++){ 1014 1018 //var format =(aFormats[i].textContent)? aFormats[i].textContent:aFormats[i].text; 1015 var format = Sarissa.getText(aFormats[i]);1019 if(aFormats[i])var format = OpenLayers.Ajax.getText(aFormats[i]); 1016 1020 if(format == 'image/png' || format == 'image/jpeg' || format == 'image/gif')oFormats.push(format); 1017 1021 } … … 1026 1030 if(resolutions.length){ 1027 1031 //var resolutionsS = resolutions[0].textContent; 1028 var resolutionsS = Sarissa.getText(resolutions[0]);1032 var resolutionsS = OpenLayers.Ajax.getText(resolutions[0]); 1029 1033 if(resolutionsS.length){ 1030 1034 var aResolutions = resolutionsS.split(' '); … … 1035 1039 } 1036 1040 1037 1038 1041 //Print Layer List 1039 1042 var aLayer = xml.getElementsByTagName('Layer'); … … 1042 1045 this.WMSManager.drawLayersForm(xml); 1043 1046 } 1047 1044 1048 } else { 1045 1049 alert('connection error: response is not an object'); … … 1098 1102 //if(nameNode)var Name =(nameNode.textContent)? nameNode.textContent:nameNode.text; 1099 1103 //else var Name = null; 1100 if(nameNode)var Name = Sarissa.getText(nameNode);1104 if(nameNode)var Name =OpenLayers.Ajax.getText(nameNode); 1101 1105 else var Name = null; 1102 1106 … … 1104 1108 //if(titleNode)var Title =(titleNode.textContent)? titleNode.textContent:titleNode.text; 1105 1109 //else var Title = null; 1106 if(titleNode)var Title = Sarissa.getText(titleNode);1110 if(titleNode)var Title = OpenLayers.Ajax.getText(titleNode); 1107 1111 else var Title = null; 1108 1112 … … 1152 1156 //if(nameNode)var Name =(nameNode.textContent)? nameNode.textContent:nameNode.text; 1153 1157 //else var Name = null; 1154 if(nameNode)var Name = Sarissa.getText(nameNode);1158 if(nameNode)var Name =OpenLayers.Ajax.getText(nameNode); 1155 1159 else var Name = null; 1156 1160 //alert(nameNode.data); … … 1160 1164 //if(titleNode)var Title =(titleNode.textContent)? titleNode.textContent:titleNode.text; 1161 1165 //else var Title = null; 1162 if(titleNode)var Title = Sarissa.getText(titleNode);1166 if(titleNode)var Title =OpenLayers.Ajax.getText(titleNode); 1163 1167 else var Title = null; 1164 1168 … … 1167 1171 //if(abstractNode) var Abstract =(abstractNode.textContent)? abstractNode.textContent:abstractNode.text; 1168 1172 //else var Abstract = null; 1169 if(abstractNode)var Abstract = Sarissa.getText(abstractNode);1173 if(abstractNode)var Abstract =OpenLayers.Ajax.getText(abstractNode); 1170 1174 else var Abstract = null; 1171 1175 … … 1632 1636 } 1633 1637 }, 1638 1639 1634 1640 1635 1641 /** @final @type String */ 1636 1642 CLASS_NAME: "OpenLayers.Control.WMSManager" 1637 1643 }); 1644 1645 1646 /** Sarissa derived getText 1647 * 1648 * @private 1649 * 1650 * @param {Node} XML node 1651 * @param {int} deep recursion 1652 */ 1653 OpenLayers.Ajax.getText = function(oNode, deep){ 1654 var s = ""; 1655 var nodes = oNode.childNodes; 1656 for(var i=0; i < nodes.length; i++){ 1657 var node = nodes[i]; 1658 var nodeType = node.nodeType; 1659 if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){ 1660 s += node.data; 1661 } else if(deep == true 1662 && (nodeType == Node.ELEMENT_NODE 1663 || nodeType == Node.DOCUMENT_NODE 1664 || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){ 1665 s += OpenLayers.Ajax.getText.getText(node, true); 1666 }; 1667 }; 1668 return s; 1669 } 1670 1671 /** Sarissa derived getParseErrorText 1672 * 1673 * @private 1674 * 1675 * @param {Document} oDoc The target DOM document 1676 * @returns The parsing error description of the target Document in 1677 * human readable form (preformated text) 1678 */ 1679 OpenLayers.Ajax.PARSED_OK = "Document contains no parsing errors"; 1680 OpenLayers.Ajax.PARSED_EMPTY = "Document is empty"; 1681 OpenLayers.Ajax.PARSED_UNKNOWN_ERROR = "Not well-formed or other error"; 1682 1683 OpenLayers.Ajax.getParseErrorText = function(oDoc){ 1684 var parseErrorText = OpenLayers.Ajax.PARSED_OK; 1685 if(oDoc && oDoc.parseError && oDoc.parseError.errorCode && oDoc.parseError.errorCode != 0){ 1686 parseErrorText = "XML Parsing Error: " + oDoc.parseError.reason + 1687 "\nLocation: " + oDoc.parseError.url + 1688 "\nLine Number " + oDoc.parseError.line + ", Column " + 1689 oDoc.parseError.linepos + 1690 ":\n" + oDoc.parseError.srcText + 1691 "\n"; 1692 for(var i = 0; i < oDoc.parseError.linepos;i++){ 1693 parseErrorText += "-"; 1694 }; 1695 parseErrorText += "^\n"; 1696 } 1697 else if(oDoc.documentElement == null){ 1698 parseErrorText = OpenLayers.Ajax.PARSED_EMPTY; 1699 }; 1700 return parseErrorText; 1701 } 1702 1703 /** 1704 * Sarissa derived Escape 1705 * Escape the given string chacters that correspond to the five predefined XML entities 1706 * @param sXml the string to escape 1707 */ 1708 OpenLayers.Ajax.escape = function(sXml){ 1709 return sXml.replace(/&/g, "&") 1710 .replace(/</g, "<") 1711 .replace(/>/g, ">") 1712 .replace(/"/g, """) 1713 .replace(/'/g, "'"); 1714 } 1715 /** 1716 * Sarissa derived Unescape 1717 * Unescape the given string. This turns the occurences of the predefined XML 1718 * entities to become the characters they represent correspond to the five predefined XML entities 1719 * @param sXml the string to unescape 1720 */ 1721 OpenLayers.Ajax.unescape = function(sXml){ 1722 return sXml.replace(/'/g,"'") 1723 .replace(/"/g,"\"") 1724 .replace(/>/g,">") 1725 .replace(/</g,"<") 1726 .replace(/&/g,"&"); 1727 } 1728 1729 /** 1730 * Sarissa node values definition 1731 * 1732 */ 1733 if(!window.Node || !Node.ELEMENT_NODE){ 1734 Node = {ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5, ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12}; 1735 }
