1.1 --- a/examples/Common/VerySimpleWithLogin/Resources/scripts/sarissa.js Sun Sep 09 16:47:37 2007 +0000
1.2 +++ b/examples/Common/VerySimpleWithLogin/Resources/scripts/sarissa.js Sun Sep 09 16:47:54 2007 +0000
1.3 @@ -6,7 +6,8 @@
1.4 * The library supports Gecko based browsers like Mozilla and Firefox,
1.5 * Internet Explorer (5.5+ with MSXML3.0+), Konqueror, Safari and a little of Opera
1.6 * @version ${project.version}
1.7 - * @author: Manos Batsis, mailto: mbatsis at users full stop sourceforge full stop net
1.8 + * @author: @author: Copyright 2004-2007 Emmanouil Batsis, mailto: mbatsis at users full stop sourceforge full stop net
1.9 + *
1.10 * ====================================================================
1.11 * Licence
1.12 * ====================================================================
1.13 @@ -17,6 +18,7 @@
1.14 * In case your copy of Sarissa does not include the license texts, you may find
1.15 * them online in various formats at <a href="http://www.gnu.org">http://www.gnu.org</a> and
1.16 * <a href="http://www.apache.org">http://www.apache.org</a>.
1.17 + *
1.18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
1.19 * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
1.20 * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
1.21 @@ -43,12 +45,25 @@
1.22 var _SARISSA_HAS_DOM_CREATE_DOCUMENT = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.createDocument;
1.23 var _SARISSA_HAS_DOM_FEATURE = _SARISSA_HAS_DOM_IMPLEMENTATION && document.implementation.hasFeature;
1.24 var _SARISSA_IS_MOZ = _SARISSA_HAS_DOM_CREATE_DOCUMENT && _SARISSA_HAS_DOM_FEATURE;
1.25 -var _SARISSA_IS_SAFARI = (navigator.userAgent && navigator.vendor && (navigator.userAgent.toLowerCase().indexOf("applewebkit") != -1 || navigator.vendor.indexOf("Apple") != -1));
1.26 +var _SARISSA_IS_SAFARI = navigator.userAgent.toLowerCase().indexOf("safari") != -1 || navigator.userAgent.toLowerCase().indexOf("konqueror") != -1;
1.27 +var _SARISSA_IS_SAFARI_OLD = _SARISSA_IS_SAFARI && parseInt((navigator.userAgent.match(/AppleWebKit\/(\d+)/)||{})[1]) < 420;
1.28 var _SARISSA_IS_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1;
1.29 +var _SARISSA_IS_OPERA = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
1.30 if(!window.Node || !Node.ELEMENT_NODE){
1.31 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};
1.32 };
1.33
1.34 +//This breaks for(x in o) loops in the old Safari
1.35 +if(_SARISSA_IS_SAFARI_OLD){
1.36 + HTMLHtmlElement = document.createElement("html").constructor;
1.37 + Node = HTMLElement = {};
1.38 + HTMLElement.prototype = HTMLHtmlElement.__proto__.__proto__;
1.39 + HTMLDocument = Document = document.constructor;
1.40 + var x = new DOMParser();
1.41 + XMLDocument = x.constructor;
1.42 + Element = x.parseFromString("<Single />", "text/xml").documentElement.constructor;
1.43 + x = null;
1.44 +}
1.45 if(typeof XMLDocument == "undefined" && typeof Document !="undefined"){ XMLDocument = Document; }
1.46
1.47 // IE initialization
1.48 @@ -68,18 +83,19 @@
1.49 */
1.50 Sarissa.pickRecentProgID = function (idList){
1.51 // found progID flag
1.52 - var bFound = false;
1.53 + var bFound = false, e;
1.54 for(var i=0; i < idList.length && !bFound; i++){
1.55 try{
1.56 var oDoc = new ActiveXObject(idList[i]);
1.57 - o2Store = idList[i];
1.58 + var o2Store = idList[i];
1.59 bFound = true;
1.60 }catch (objException){
1.61 // trap; try next progID
1.62 + e = objException;
1.63 };
1.64 };
1.65 if (!bFound) {
1.66 - throw "Could not retreive a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
1.67 + throw "Could not retrieve a valid progID of Class: " + idList[idList.length-1]+". (original exception: "+e+")";
1.68 };
1.69 idList = null;
1.70 return o2Store;
1.71 @@ -184,12 +200,15 @@
1.72 // convert stylesheet to free threaded
1.73 var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);
1.74 // make included/imported stylesheets work if exist and xsl was originally loaded from url
1.75 + try{
1.76 + converted.resolveExternals = true;
1.77 + converted.setProperty("AllowDocumentFunction", true);
1.78 + }
1.79 + catch(e){
1.80 + // Ignore. "AllowDocumentFunction" is only supported in MSXML 3.0 SP4 and later.
1.81 + };
1.82 if(xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null){
1.83 converted.async = false;
1.84 - if (_SARISSA_THREADEDDOM_PROGID == "MSXML2.FreeThreadedDOMDocument.6.0") {
1.85 - converted.setProperty("AllowDocumentFunction", true);
1.86 - converted.resolveExternals = true;
1.87 - }
1.88 converted.load(xslDoc.url);
1.89 } else {
1.90 converted.loadXML(xslDoc.xml);
1.91 @@ -200,7 +219,7 @@
1.92 this.template.stylesheet = converted;
1.93 this.processor = this.template.createProcessor();
1.94 // for getParameter and clearParameters
1.95 - this.paramsSet = new Array();
1.96 + this.paramsSet = [];
1.97 };
1.98
1.99 /**
1.100 @@ -273,21 +292,22 @@
1.101 * @argument name The parameter base name
1.102 * @argument value The new parameter value
1.103 */
1.104 - XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
1.105 - // make value a zero length string if null to allow clearing
1.106 - value = value ? value : "";
1.107 - // nsURI is optional but cannot be null
1.108 - if(nsURI){
1.109 - this.processor.addParameter(name, value, nsURI);
1.110 - }else{
1.111 - this.processor.addParameter(name, value);
1.112 - };
1.113 - // update updated params for getParameter
1.114 - if(!this.paramsSet[""+nsURI]){
1.115 - this.paramsSet[""+nsURI] = new Array();
1.116 - };
1.117 - this.paramsSet[""+nsURI][name] = value;
1.118 - };
1.119 + XSLTProcessor.prototype.setParameter = function(nsURI, name, value){
1.120 + // make value a zero length string if null to allow clearing
1.121 + value = value ? value : "";
1.122 + // nsURI is optional but cannot be null
1.123 + if(nsURI){
1.124 + this.processor.addParameter(name, value, nsURI);
1.125 + }else{
1.126 + this.processor.addParameter(name, value);
1.127 + };
1.128 + // update updated params for getParameter
1.129 + nsURI = "" + (nsURI || "");
1.130 + if(!this.paramsSet[nsURI]){
1.131 + this.paramsSet[nsURI] = new Array();
1.132 + };
1.133 + this.paramsSet[nsURI][name] = value;
1.134 + };
1.135 /**
1.136 * Gets a parameter if previously set by setParameter. Returns null
1.137 * otherwise
1.138 @@ -296,7 +316,7 @@
1.139 * @return The parameter value if reviously set by setParameter, null otherwise
1.140 */
1.141 XSLTProcessor.prototype.getParameter = function(nsURI, name){
1.142 - nsURI = "" + nsURI;
1.143 + nsURI = "" + (nsURI || "");
1.144 if(this.paramsSet[nsURI] && this.paramsSet[nsURI][name]){
1.145 return this.paramsSet[nsURI][name];
1.146 }else{
1.147 @@ -309,7 +329,7 @@
1.148 XSLTProcessor.prototype.clearParameters = function(){
1.149 for(var nsURI in this.paramsSet){
1.150 for(var name in this.paramsSet[nsURI]){
1.151 - if(nsURI){
1.152 + if(nsURI!=""){
1.153 this.processor.addParameter(name, "", nsURI);
1.154 }else{
1.155 this.processor.addParameter(name, "");
1.156 @@ -346,8 +366,9 @@
1.157 Sarissa.__setReadyState__ = function(oDoc, iReadyState){
1.158 oDoc.readyState = iReadyState;
1.159 oDoc.readystate = iReadyState;
1.160 - if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function")
1.161 + if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function") {
1.162 oDoc.onreadystatechange();
1.163 + }
1.164 };
1.165 Sarissa.getDomDocument = function(sUri, sName){
1.166 var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
1.167 @@ -421,7 +442,7 @@
1.168 xmlhttp.send(null);
1.169 return xmlhttp.responseXML;
1.170 };
1.171 - }else if(Sarissa.getDomDocument && Sarissa.getDomDocument()){
1.172 + }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){
1.173 DOMParser = function() { };
1.174 DOMParser.prototype.parseFromString = function(sXml, contentType){
1.175 var doc = Sarissa.getDomDocument();
1.176 @@ -554,6 +575,10 @@
1.177 * @argument bPreserveExisting whether to preserve the original content of nodeTo, default is false
1.178 */
1.179 Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
1.180 + if(_SARISSA_IS_SAFARI && nodeTo.nodeType == Node.DOCUMENT_NODE){ // SAFARI_OLD ??
1.181 + nodeTo = nodeTo.documentElement; //Appearantly there's a bug in safari where you can't appendChild to a document node
1.182 + }
1.183 +
1.184 if((!nodeFrom) || (!nodeTo)){
1.185 throw "Both source and destination nodes must be provided";
1.186 };
1.187 @@ -610,12 +635,12 @@
1.188 };
1.189
1.190 /**
1.191 - * <p>Serialize any object to an XML string. All properties are serialized using the property name
1.192 + * <p>Serialize any <strong>non</strong> DOM object to an XML string. All properties are serialized using the property name
1.193 * as the XML element name. Array elements are rendered as <code>array-item</code> elements,
1.194 * using their index/key as the value of the <code>key</code> attribute.</p>
1.195 * @argument anyObject the object to serialize
1.196 * @argument objectName a name for that object
1.197 - * @return the XML serializationj of the given object as a string
1.198 + * @return the XML serialization of the given object as a string
1.199 */
1.200 Sarissa.xmlize = function(anyObject, objectName, indentSpace){
1.201 indentSpace = indentSpace?indentSpace:'';
1.202 @@ -627,14 +652,13 @@
1.203 isLeaf = true;
1.204 }else{
1.205 s += "\n";
1.206 - var itemKey = '';
1.207 var isArrayItem = anyObject instanceof Array;
1.208 for(var name in anyObject){
1.209 s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + " ");
1.210 };
1.211 s += indentSpace;
1.212 };
1.213 - return s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n");
1.214 + return (s += (objectName.indexOf(' ')!=-1?"</array-item>\n":"</" + objectName + ">\n"));
1.215 };
1.216
1.217 /**