Emulates IE's readyState property, which always gives an integer from 0 to 4:
+ *
1 == LOADING,
+ *
2 == LOADED,
+ *
3 == INTERACTIVE,
+ *
4 == COMPLETED
+ */
+ oDoc.readyState = 0;
+ }
+ oDoc.addEventListener("load", _sarissa_XMLDocument_onload, false);
+ return oDoc;
+ };
+ if(window.XMLDocument){
+ // do nothing
+ }// TODO: check if the new document has content before trying to copynodes, check for error handling in DOM 3 LS
+ else if(Sarissa._SARISSA_HAS_DOM_FEATURE && window.Document && !Document.prototype.load && document.implementation.hasFeature('LS', '3.0')){
+ //Opera 9 may get the XPath branch which gives creates XMLDocument, therefore it doesn't reach here which is good
+ /**
+ *
Factory method to obtain a new DOM Document object
+ * @memberOf Sarissa
+ * @param {String} sUri the namespace of the root node (if any)
+ * @param {String} sUri the local name of the root node (if any)
+ * @returns {DOMDOcument} a new DOM Document
+ */
+ Sarissa.getDomDocument = function(sUri, sName){
+ var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
+ return oDoc;
+ };
+ }
+ else {
+ Sarissa.getDomDocument = function(sUri, sName){
+ var oDoc = document.implementation.createDocument(sUri?sUri:null, sName?sName:null, null);
+ // looks like safari does not create the root element for some unknown reason
+ if(oDoc && (sUri || sName) && !oDoc.documentElement){
+ oDoc.appendChild(oDoc.createElementNS(sUri, sName));
+ }
+ return oDoc;
+ };
+ }
+ }//if(Sarissa._SARISSA_HAS_DOM_CREATE_DOCUMENT)
+}
+//==========================================
+// Common stuff
+//==========================================
+if(!window.DOMParser){
+ if(Sarissa._SARISSA_IS_SAFARI){
+ /**
+ * DOMParser is a utility class, used to construct DOMDocuments from XML strings
+ * @constructor
+ */
+ DOMParser = function() { };
+ /**
+ * Construct a new DOM Document from the given XMLstring
+ * @param {String} sXml the given XML string
+ * @param {String} contentType the content type of the document the given string represents (one of text/xml, application/xml, application/xhtml+xml).
+ * @return {DOMDocument} a new DOM Document from the given XML string
+ */
+ DOMParser.prototype.parseFromString = function(sXml, contentType){
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("GET", "data:text/xml;charset=utf-8," + encodeURIComponent(sXml), false);
+ xmlhttp.send(null);
+ return xmlhttp.responseXML;
+ };
+ }else if(Sarissa.getDomDocument && Sarissa.getDomDocument() && Sarissa.getDomDocument(null, "bar").xml){
+ DOMParser = function() { };
+ DOMParser.prototype.parseFromString = function(sXml, contentType){
+ var doc = Sarissa.getDomDocument();
+ doc.loadXML(sXml);
+ return doc;
+ };
+ }
+}
+
+if((typeof(document.importNode) == "undefined") && Sarissa._SARISSA_IS_IE){
+ try{
+ /**
+ * Implementation of importNode for the context window document in IE.
+ * If oNode is a TextNode, bChildren is ignored.
+ * @param {DOMNode} oNode the Node to import
+ * @param {boolean} bChildren whether to include the children of oNode
+ * @returns the imported node for further use
+ */
+ document.importNode = function(oNode, bChildren){
+ var tmp;
+ if (oNode.nodeName=='#text') {
+ return document.createTextNode(oNode.data);
+ }
+ else {
+ if(oNode.nodeName == "tbody" || oNode.nodeName == "tr"){
+ tmp = document.createElement("table");
+ }
+ else if(oNode.nodeName == "td"){
+ tmp = document.createElement("tr");
+ }
+ else if(oNode.nodeName == "option"){
+ tmp = document.createElement("select");
+ }
+ else{
+ tmp = document.createElement("div");
+ }
+ if(bChildren){
+ tmp.innerHTML = oNode.xml ? oNode.xml : oNode.outerHTML;
+ }else{
+ tmp.innerHTML = oNode.xml ? oNode.cloneNode(false).xml : oNode.cloneNode(false).outerHTML;
+ }
+ return tmp.getElementsByTagName("*")[0];
+ }
+ };
+ }catch(e){ }
+}
+if(!Sarissa.getParseErrorText){
+ /**
+ *
Returns a human readable description of the parsing error. Usefull
+ * for debugging. Tip: append the returned error string in a <pre>
+ * element if you want to render it.
+ *
Many thanks to Christian Stocker for the initial patch.
+ * @memberOf Sarissa
+ * @param {DOMDocument} oDoc The target DOM document
+ * @returns {String} The parsing error description of the target Document in
+ * human readable form (preformated text)
+ */
+ Sarissa.getParseErrorText = function (oDoc){
+ var parseErrorText = Sarissa.PARSED_OK;
+ if((!oDoc) || (!oDoc.documentElement)){
+ parseErrorText = Sarissa.PARSED_EMPTY;
+ } else if(oDoc.documentElement.tagName == "parsererror"){
+ parseErrorText = oDoc.documentElement.firstChild.data;
+ parseErrorText += "\n" + oDoc.documentElement.firstChild.nextSibling.firstChild.data;
+ } else if(oDoc.getElementsByTagName("parsererror").length > 0){
+ var parsererror = oDoc.getElementsByTagName("parsererror")[0];
+ parseErrorText = Sarissa.getText(parsererror, true)+"\n";
+ } else if(oDoc.parseError && oDoc.parseError.errorCode != 0){
+ parseErrorText = Sarissa.PARSED_UNKNOWN_ERROR;
+ }
+ return parseErrorText;
+ };
+}
+/**
+ * Get a string with the concatenated values of all string nodes under the given node
+ * @param {DOMNode} oNode the given DOM node
+ * @param {boolean} deep whether to recursively scan the children nodes of the given node for text as well. Default is false
+ * @memberOf Sarissa
+ */
+Sarissa.getText = function(oNode, deep){
+ var s = "";
+ var nodes = oNode.childNodes;
+ for(var i=0; i < nodes.length; i++){
+ var node = nodes[i];
+ var nodeType = node.nodeType;
+ if(nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE){
+ s += node.data;
+ } else if(deep === true && (nodeType == Node.ELEMENT_NODE || nodeType == Node.DOCUMENT_NODE || nodeType == Node.DOCUMENT_FRAGMENT_NODE)){
+ s += Sarissa.getText(node, true);
+ }
+ }
+ return s;
+};
+if(!window.XMLSerializer && Sarissa.getDomDocument && Sarissa.getDomDocument("","foo", null).xml){
+ /**
+ * Utility class to serialize DOM Node objects to XML strings
+ * @constructor
+ */
+ XMLSerializer = function(){};
+ /**
+ * Serialize the given DOM Node to an XML string
+ * @param {DOMNode} oNode the DOM Node to serialize
+ */
+ XMLSerializer.prototype.serializeToString = function(oNode) {
+ return oNode.xml;
+ };
+}
+
+/**
+ * Strips tags from the given markup string. If the given string is
+ * undefined, null or empty, it is returned as is.
+ * @memberOf Sarissa
+ * @param {String} s the string to strip the tags from
+ */
+Sarissa.stripTags = function (s) {
+ return s?s.replace(/<[^>]+>/g,""):s;
+};
+/**
+ *
Deletes all child nodes of the given node
+ * @memberOf Sarissa
+ * @param {DOMNode} oNode the Node to empty
+ */
+Sarissa.clearChildNodes = function(oNode) {
+ // need to check for firstChild due to opera 8 bug with hasChildNodes
+ while(oNode.firstChild) {
+ oNode.removeChild(oNode.firstChild);
+ }
+};
+/**
+ *
Copies the childNodes of nodeFrom to nodeTo
+ *
Note: The second object's original content is deleted before
+ * the copy operation, unless you supply a true third parameter
+ * @memberOf Sarissa
+ * @param {DOMNode} nodeFrom the Node to copy the childNodes from
+ * @param {DOMNode} nodeTo the Node to copy the childNodes to
+ * @param {boolean} bPreserveExisting whether to preserve the original content of nodeTo, default is false
+ */
+Sarissa.copyChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
+ if(Sarissa._SARISSA_IS_SAFARI && nodeTo.nodeType == Node.DOCUMENT_NODE){ // SAFARI_OLD ??
+ nodeTo = nodeTo.documentElement; //Apparently there's a bug in safari where you can't appendChild to a document node
+ }
+
+ if((!nodeFrom) || (!nodeTo)){
+ throw "Both source and destination nodes must be provided";
+ }
+ if(!bPreserveExisting){
+ Sarissa.clearChildNodes(nodeTo);
+ }
+ var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
+ var nodes = nodeFrom.childNodes;
+ var i;
+ if(typeof(ownerDoc.importNode) != "undefined") {
+ for(i=0;i < nodes.length;i++) {
+ nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
+ }
+ } else {
+ for(i=0;i < nodes.length;i++) {
+ nodeTo.appendChild(nodes[i].cloneNode(true));
+ }
+ }
+};
+
+/**
+ *
Moves the childNodes of nodeFrom to nodeTo
+ *
Note: The second object's original content is deleted before
+ * the move operation, unless you supply a true third parameter
+ * @memberOf Sarissa
+ * @param {DOMNode} nodeFrom the Node to copy the childNodes from
+ * @param {DOMNode} nodeTo the Node to copy the childNodes to
+ * @param {boolean} bPreserveExisting whether to preserve the original content of nodeTo, default is
+ */
+Sarissa.moveChildNodes = function(nodeFrom, nodeTo, bPreserveExisting) {
+ if((!nodeFrom) || (!nodeTo)){
+ throw "Both source and destination nodes must be provided";
+ }
+ if(!bPreserveExisting){
+ Sarissa.clearChildNodes(nodeTo);
+ }
+ var nodes = nodeFrom.childNodes;
+ // if within the same doc, just move, else copy and delete
+ if(nodeFrom.ownerDocument == nodeTo.ownerDocument){
+ while(nodeFrom.firstChild){
+ nodeTo.appendChild(nodeFrom.firstChild);
+ }
+ } else {
+ var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument;
+ var i;
+ if(typeof(ownerDoc.importNode) != "undefined") {
+ for(i=0;i < nodes.length;i++) {
+ nodeTo.appendChild(ownerDoc.importNode(nodes[i], true));
+ }
+ }else{
+ for(i=0;i < nodes.length;i++) {
+ nodeTo.appendChild(nodes[i].cloneNode(true));
+ }
+ }
+ Sarissa.clearChildNodes(nodeFrom);
+ }
+};
+
+/**
+ *
Serialize any non DOM object to an XML string. All properties are serialized using the property name
+ * as the XML element name. Array elements are rendered as array-item elements,
+ * using their index/key as the value of the key attribute.
+ * @memberOf Sarissa
+ * @param {Object} anyObject the object to serialize
+ * @param {String} objectName a name for that object, to be used as the root element name
+ * @return {String} the XML serialization of the given object as a string
+ */
+Sarissa.xmlize = function(anyObject, objectName, indentSpace){
+ indentSpace = indentSpace?indentSpace:'';
+ var s = indentSpace + '<' + objectName + '>';
+ var isLeaf = false;
+ if(!(anyObject instanceof Object) || anyObject instanceof Number || anyObject instanceof String || anyObject instanceof Boolean || anyObject instanceof Date){
+ s += Sarissa.escape(""+anyObject);
+ isLeaf = true;
+ }else{
+ s += "\n";
+ var isArrayItem = anyObject instanceof Array;
+ for(var name in anyObject){
+ s += Sarissa.xmlize(anyObject[name], (isArrayItem?"array-item key=\""+name+"\"":name), indentSpace + " ");
+ }
+ s += indentSpace;
+ }
+ return (s += (objectName.indexOf(' ')!=-1?"\n":"" + objectName + ">\n"));
+};
+
+/**
+ * Escape the given string chacters that correspond to the five predefined XML entities
+ * @memberOf Sarissa
+ * @param {String} sXml the string to escape
+ */
+Sarissa.escape = function(sXml){
+ return sXml.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'");
+};
+
+/**
+ * Unescape the given string. This turns the occurences of the predefined XML
+ * entities to become the characters they represent correspond to the five predefined XML entities
+ * @memberOf Sarissa
+ * @param {String}sXml the string to unescape
+ */
+Sarissa.unescape = function(sXml){
+ return sXml.replace(/'/g,"'").replace(/"/g,"\"").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&");
+};
+
+/** @private */
+Sarissa.updateCursor = function(oTargetElement, sValue) {
+ if(oTargetElement && oTargetElement.style && oTargetElement.style.cursor != undefined ){
+ oTargetElement.style.cursor = sValue;
+ }
+};
+
+/**
+ * Asynchronously update an element with response of a GET request on the given URL. Passing a configured XSLT
+ * processor will result in transforming and updating oNode before using it to update oTargetElement.
+ * You can also pass a callback function to be executed when the update is finished. The function will be called as
+ * functionName(oNode, oTargetElement);
+ * @memberOf Sarissa
+ * @param {String} sFromUrl the URL to make the request to
+ * @param {DOMElement} oTargetElement the element to update
+ * @param {XSLTProcessor} xsltproc (optional) the transformer to use on the returned
+ * content before updating the target element with it
+ * @param {Function} callback (optional) a Function object to execute once the update is finished successfuly, called as callback(sFromUrl, oTargetElement).
+ * In case an exception is thrown during execution, the callback is called as called as callback(sFromUrl, oTargetElement, oException)
+ * @param {boolean} skipCache (optional) whether to skip any cache
+ */
+Sarissa.updateContentFromURI = function(sFromUrl, oTargetElement, xsltproc, callback, skipCache) {
+ try{
+ Sarissa.updateCursor(oTargetElement, "wait");
+ var xmlhttp = new XMLHttpRequest();
+ xmlhttp.open("GET", sFromUrl, true);
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState == 4) {
+ try{
+ var oDomDoc = xmlhttp.responseXML;
+ if(oDomDoc && Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
+ Sarissa.updateContentFromNode(xmlhttp.responseXML, oTargetElement, xsltproc);
+ if(callback){
+ callback(sFromUrl, oTargetElement);
+ }
+ }
+ else{
+ throw Sarissa.getParseErrorText(oDomDoc);
+ }
+ }
+ catch(e){
+ if(callback){
+ callback(sFromUrl, oTargetElement, e);
+ }
+ else{
+ throw e;
+ }
+ }
+ }
+ };
+ if (skipCache) {
+ var oldage = "Sat, 1 Jan 2000 00:00:00 GMT";
+ xmlhttp.setRequestHeader("If-Modified-Since", oldage);
+ }
+ xmlhttp.send("");
+ }
+ catch(e){
+ Sarissa.updateCursor(oTargetElement, "auto");
+ if(callback){
+ callback(sFromUrl, oTargetElement, e);
+ }
+ else{
+ throw e;
+ }
+ }
+};
+
+/**
+ * Update an element's content with the given DOM node. Passing a configured XSLT
+ * processor will result in transforming and updating oNode before using it to update oTargetElement.
+ * You can also pass a callback function to be executed when the update is finished. The function will be called as
+ * functionName(oNode, oTargetElement);
+ * @memberOf Sarissa
+ * @param {DOMNode} oNode the URL to make the request to
+ * @param {DOMElement} oTargetElement the element to update
+ * @param {XSLTProcessor} xsltproc (optional) the transformer to use on the given
+ * DOM node before updating the target element with it
+ */
+Sarissa.updateContentFromNode = function(oNode, oTargetElement, xsltproc) {
+ try {
+ Sarissa.updateCursor(oTargetElement, "wait");
+ Sarissa.clearChildNodes(oTargetElement);
+ // check for parsing errors
+ var ownerDoc = oNode.nodeType == Node.DOCUMENT_NODE?oNode:oNode.ownerDocument;
+ if(ownerDoc.parseError && ownerDoc.parseError.errorCode != 0) {
+ var pre = document.createElement("pre");
+ pre.appendChild(document.createTextNode(Sarissa.getParseErrorText(ownerDoc)));
+ oTargetElement.appendChild(pre);
+ }
+ else {
+ // transform if appropriate
+ if(xsltproc) {
+ oNode = xsltproc.transformToDocument(oNode);
+ }
+ // be smart, maybe the user wants to display the source instead
+ if(oTargetElement.tagName.toLowerCase() == "textarea" || oTargetElement.tagName.toLowerCase() == "input") {
+ oTargetElement.value = new XMLSerializer().serializeToString(oNode);
+ }
+ else {
+ // ok that was not smart; it was paranoid. Keep up the good work by trying to use DOM instead of innerHTML
+ try{
+ oTargetElement.appendChild(oTargetElement.ownerDocument.importNode(oNode, true));
+ }
+ catch(e){
+ oTargetElement.innerHTML = new XMLSerializer().serializeToString(oNode);
+ }
+ }
+ }
+ }
+ catch(e) {
+ throw e;
+ }
+ finally{
+ Sarissa.updateCursor(oTargetElement, "auto");
+ }
+};
+
+
+/**
+ * Creates an HTTP URL query string from the given HTML form data
+ * @memberOf Sarissa
+ * @param {HTMLFormElement} oForm the form to construct the query string from
+ */
+Sarissa.formToQueryString = function(oForm){
+ var qs = "";
+ for(var i = 0;i < oForm.elements.length;i++) {
+ var oField = oForm.elements[i];
+ var sFieldName = oField.getAttribute("name") ? oField.getAttribute("name") : oField.getAttribute("id");
+ // ensure we got a proper name/id and that the field is not disabled
+ if(sFieldName &&
+ ((!oField.disabled) || oField.type == "hidden")) {
+ switch(oField.type) {
+ case "hidden":
+ case "text":
+ case "textarea":
+ case "password":
+ qs += sFieldName + "=" + encodeURIComponent(oField.value) + "&";
+ break;
+ case "select-one":
+ qs += sFieldName + "=" + encodeURIComponent(oField.options[oField.selectedIndex].value) + "&";
+ break;
+ case "select-multiple":
+ for (var j = 0; j < oField.length; j++) {
+ var optElem = oField.options[j];
+ if (optElem.selected === true) {
+ qs += sFieldName + "[]" + "=" + encodeURIComponent(optElem.value) + "&";
+ }
+ }
+ break;
+ case "checkbox":
+ case "radio":
+ if(oField.checked) {
+ qs += sFieldName + "=" + encodeURIComponent(oField.value) + "&";
+ }
+ break;
+ }
+ }
+ }
+ // return after removing last '&'
+ return qs.substr(0, qs.length - 1);
+};
+
+
+/**
+ * Asynchronously update an element with response of an XMLHttpRequest-based emulation of a form submission.
The form action and
+ * method attributess will be followed. Passing a configured XSLT processor will result in
+ * transforming and updating the server response before using it to update the target element.
+ * You can also pass a callback function to be executed when the update is finished. The function will be called as
+ * functionName(oNode, oTargetElement);
+ *
Here is an example of using this in a form element:
+ *
+ * <div id="targetId"> this content will be updated</div>
+ * <form action="/my/form/handler" method="post"
+ * onbeforesubmit="return Sarissa.updateContentFromForm(this, document.getElementById('targetId'));">
+ *
If JavaScript is supported, the form will not be submitted. Instead, Sarissa will
+ * scan the form and make an appropriate AJAX request, also adding a parameter
+ * to signal to the server that this is an AJAX call. The parameter is
+ * constructed as Sarissa.REMOTE_CALL_FLAG = "=true" so you can change the name in your webpage
+ * simply by assigning another value to Sarissa.REMOTE_CALL_FLAG. If JavaScript is not supported
+ * the form will be submitted normally.
+ * @memberOf Sarissa
+ * @param {HTMLFormElement} oForm the form submition to emulate
+ * @param {DOMElement} oTargetElement the element to update
+ * @param {XSLTProcessor} xsltproc (optional) the transformer to use on the returned
+ * content before updating the target element with it
+ * @param {Function} callback (optional) a Function object to execute once the update is finished successfuly, called as callback(oNode, oTargetElement).
+ * In case an exception occurs during excecution and a callback function was provided, the exception is cought and the callback is called as
+ * callback(oForm, oTargetElement, exception)
+ */
+Sarissa.updateContentFromForm = function(oForm, oTargetElement, xsltproc, callback) {
+ try{
+ Sarissa.updateCursor(oTargetElement, "wait");
+ // build parameters from form fields
+ var params = Sarissa.formToQueryString(oForm) + "&" + Sarissa.REMOTE_CALL_FLAG + "=true";
+ var xmlhttp = new XMLHttpRequest();
+ var bUseGet = oForm.getAttribute("method") && oForm.getAttribute("method").toLowerCase() == "get";
+ if(bUseGet) {
+ xmlhttp.open("GET", oForm.getAttribute("action")+"?"+params, true);
+ }
+ else{
+ xmlhttp.open('POST', oForm.getAttribute("action"), true);
+ xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xmlhttp.setRequestHeader("Content-length", params.length);
+ xmlhttp.setRequestHeader("Connection", "close");
+ }
+ xmlhttp.onreadystatechange = function() {
+ try{
+ if (xmlhttp.readyState == 4) {
+ var oDomDoc = xmlhttp.responseXML;
+ if(oDomDoc && Sarissa.getParseErrorText(oDomDoc) == Sarissa.PARSED_OK){
+ Sarissa.updateContentFromNode(xmlhttp.responseXML, oTargetElement, xsltproc);
+ if(callback){
+ callback(oForm, oTargetElement);
+ }
+ }
+ else{
+ throw Sarissa.getParseErrorText(oDomDoc);
+ }
+ }
+ }
+ catch(e){
+ if(callback){
+ callback(oForm, oTargetElement, e);
+ }
+ else{
+ throw e;
+ }
+ }
+ };
+ xmlhttp.send(bUseGet?"":params);
+ }
+ catch(e){
+ Sarissa.updateCursor(oTargetElement, "auto");
+ if(callback){
+ callback(oForm, oTargetElement, e);
+ }
+ else{
+ throw e;
+ }
+ }
+ return false;
+};
+Sarissa.FUNCTION_NAME_REGEXP = new RegExp("");//new RegExp("function\\s+(\\S+)\\s*\\((.|\\n)*?\\)\\s*{");
+/**
+ * Get the name of a function created like:
+ *
function functionName(){}
+ * If a name is not found and the bForce parameter is true,
+ * attach the function to the window object with a new name and
+ * return that
+ * @param {Function} oFunc the function object
+ * @param {boolean} bForce whether to force a name under the window context if none is found
+ */
+Sarissa.getFunctionName = function(oFunc, bForce){
+ //alert("Sarissa.getFunctionName oFunc: "+oFunc);
+ var name;
+ if(!name){
+ if(bForce){
+ // attach to window object under a new name
+ name = "SarissaAnonymous" + Sarissa._getUniqueSuffix();
+ window[name] = oFunc;
+ }
+ else{
+ name = null;
+ }
+ }
+
+ //alert("Sarissa.getFunctionName returns: "+name);
+ if(name){
+ window[name] = oFunc;
+ }
+ return name;
+};
+
+/**
+ *
+ */
+Sarissa.setRemoteJsonCallback = function(url, callback, callbackParam) {
+ if(!callbackParam){
+ callbackParam = "callback";
+ }
+ var callbackFunctionName = Sarissa.getFunctionName(callback, true);
+ var id = "sarissa_json_script_id_" + Sarissa._getUniqueSuffix();
+ var oHead = document.getElementsByTagName("head")[0];
+ var scriptTag = document.createElement('script');
+ scriptTag.type = 'text/javascript';
+ scriptTag.id = id;
+ scriptTag.onload = function(){
+ // cleanUp
+ // document.removeChild(scriptTag);
+ };
+ if(url.indexOf("?") != -1){
+ url += ("&" + callbackParam + "=" + callbackFunctionName);
+ }
+ else{
+ url += ("?" + callbackParam + "=" + callbackFunctionName);
+ }
+ scriptTag.src = url;
+ oHead.appendChild(scriptTag);
+ return id;
+};
+
+// EOF
diff --git a/pacotes/cswclient/lib/scripts/sarissa_ieemu_xpath.js b/pacotes/cswclient/lib/scripts/sarissa_ieemu_xpath.js
new file mode 100644
index 0000000..049013a
--- /dev/null
+++ b/pacotes/cswclient/lib/scripts/sarissa_ieemu_xpath.js
@@ -0,0 +1,220 @@
+/**
+ * ====================================================================
+ * About
+ * ====================================================================
+ * Sarissa cross browser XML library - IE XPath Emulation
+ * @version 0.9.9.4
+ * @author: Copyright 2004-2007 Emmanouil Batsis, mailto: mbatsis at users full stop sourceforge full stop net
+ *
+ * This script emulates Internet Explorer's selectNodes and selectSingleNode
+ * for Mozilla. Associating namespace prefixes with URIs for your XPath queries
+ * is easy with IE's setProperty.
+ * USers may also map a namespace prefix to a default (unprefixed) namespace in the
+ * source document with Sarissa.setXpathNamespaces
+ *
+ * ====================================================================
+ * Licence
+ * ====================================================================
+ * Sarissa is free software distributed under the GNU GPL version 2 (see gpl.txt) or higher,
+ * GNU LGPL version 2.1 (see lgpl.txt) or higher and Apache Software License 2.0 or higher
+ * (see asl.txt). This means you can choose one of the three and use that if you like. If
+ * you make modifications under the ASL, i would appreciate it if you submitted those.
+ * In case your copy of Sarissa does not include the license texts, you may find
+ * them online in various formats at http://www.gnu.org and
+ * http://www.apache.org.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+ * KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE
+ * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+if(Sarissa._SARISSA_HAS_DOM_FEATURE && document.implementation.hasFeature("XPath", "3.0")){
+ /**
+ *
SarissaNodeList behaves as a NodeList but is only used as a result to selectNodes,
+ * so it also has some properties IEs proprietery object features.
+ * @private
+ * @constructor
+ * @argument i the (initial) list size
+ */
+ SarissaNodeList = function (i){
+ this.length = i;
+ };
+ /**
+ *
Returns the node at the specified index or null if the given index
+ * is greater than the list size or less than zero
+ *
Note that in ECMAScript you can also use the square-bracket
+ * array notation instead of calling item
+ * @argument i the index of the member to return
+ * @returns the member corresponding to the given index
+ * @private
+ */
+ SarissaNodeList.prototype.item = function(i) {
+ return (i < 0 || i >= this.length)?null:this[i];
+ };
+ /**
+ *
Emulate IE's expr property
+ * (Here the SarissaNodeList object is given as the result of selectNodes).
+ * @returns the XPath expression passed to selectNodes that resulted in
+ * this SarissaNodeList
+ * @private
+ */
+ SarissaNodeList.prototype.expr = "";
+ /** dummy, used to accept IE's stuff without throwing errors */
+ if(window.XMLDocument && (!XMLDocument.prototype.setProperty)){
+ XMLDocument.prototype.setProperty = function(x,y){};
+ }
+ /**
+ *
Programmatically control namespace URI/prefix mappings for XPath
+ * queries.
+ *
This method comes especially handy when used to apply XPath queries
+ * on XML documents with a default namespace, as there is no other way
+ * of mapping that to a prefix.
+ *
Using no namespace prefix in DOM Level 3 XPath queries, implies you
+ * are looking for elements in the null namespace. If you need to look
+ * for nodes in the default namespace, you need to map a prefix to it
+ * first like:
Note 1 : Use this method only if the source document features
+ * a default namespace (without a prefix), otherwise just use IE's setProperty
+ * (moz will rezolve non-default namespaces by itself). You will need to map that
+ * namespace to a prefix for queries to work.
+ *
Note 2 : This method calls IE's setProperty method to set the
+ * appropriate namespace-prefix mappings, so you dont have to do that.
+ * @param oDoc The target XMLDocument to set the namespace mappings for.
+ * @param sNsSet A whilespace-seperated list of namespace declarations as
+ * those would appear in an XML document. E.g.:
+ * "xmlns:xhtml='http://www.w3.org/1999/xhtml'
+ * xmlns:'http://www.w3.org/1999/XSL/Transform'"
+ * @throws An error if the format of the given namespace declarations is bad.
+ */
+ Sarissa.setXpathNamespaces = function(oDoc, sNsSet) {
+ //oDoc._sarissa_setXpathNamespaces(sNsSet);
+ oDoc._sarissa_useCustomResolver = true;
+ var namespaces = sNsSet.indexOf(" ")>-1?sNsSet.split(" "):[sNsSet];
+ oDoc._sarissa_xpathNamespaces = [];
+ for(var i=0;i < namespaces.length;i++){
+ var ns = namespaces[i];
+ var colonPos = ns.indexOf(":");
+ var assignPos = ns.indexOf("=");
+ if(colonPos > 0 && assignPos > colonPos+1){
+ var prefix = ns.substring(colonPos+1, assignPos);
+ var uri = ns.substring(assignPos+2, ns.length-1);
+ oDoc._sarissa_xpathNamespaces[prefix] = uri;
+ }else{
+ throw "Bad format on namespace declaration(s) given";
+ }
+ }
+ };
+ /**
+ * @private Flag to control whether a custom namespace resolver should
+ * be used, set to true by Sarissa.setXpathNamespaces
+ */
+ XMLDocument.prototype._sarissa_useCustomResolver = false;
+ /** @private */
+ XMLDocument.prototype._sarissa_xpathNamespaces = [];
+ /**
+ *
Extends the XMLDocument to emulate IE's selectNodes.
+ * @argument sExpr the XPath expression to use
+ * @argument contextNode this is for internal use only by the same
+ * method when called on Elements
+ * @returns the result of the XPath search as a SarissaNodeList
+ * @throws An error if no namespace URI is found for the given prefix.
+ */
+ XMLDocument.prototype.selectNodes = function(sExpr, contextNode, returnSingle){
+ var nsDoc = this;
+ var nsresolver;
+ if(this._sarissa_useCustomResolver){
+ nsresolver = function(prefix){
+ var s = nsDoc._sarissa_xpathNamespaces[prefix];
+ if(s){
+ return s;
+ }
+ else {
+ throw "No namespace URI found for prefix: '" + prefix+"'";
+ }
+ };
+ }
+ else{
+ nsresolver = this.createNSResolver(this.documentElement);
+ }
+ var result = null;
+ if(!returnSingle){
+ var oResult = this.evaluate(sExpr,
+ (contextNode?contextNode:this),
+ nsresolver,
+ XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+ var nodeList = new SarissaNodeList(oResult.snapshotLength);
+ nodeList.expr = sExpr;
+ for(var i=0;iExtends the Element to emulate IE's selectNodes
+ * @argument sExpr the XPath expression to use
+ * @returns the result of the XPath search as an (Sarissa)NodeList
+ * @throws An
+ * error if invoked on an HTML Element as this is only be
+ * available to XML Elements.
+ */
+ Element.prototype.selectNodes = function(sExpr){
+ var doc = this.ownerDocument;
+ if(doc.selectNodes){
+ return doc.selectNodes(sExpr, this);
+ }
+ else{
+ throw "Method selectNodes is only supported by XML Elements";
+ }
+ };
+ /**
+ *
Extends the XMLDocument to emulate IE's selectSingleNode.
+ * @argument sExpr the XPath expression to use
+ * @argument contextNode this is for internal use only by the same
+ * method when called on Elements
+ * @returns the result of the XPath search as an (Sarissa)NodeList
+ */
+ XMLDocument.prototype.selectSingleNode = function(sExpr, contextNode){
+ var ctx = contextNode?contextNode:null;
+ return this.selectNodes(sExpr, ctx, true);
+ };
+ /**
+ *
Extends the Element to emulate IE's selectSingleNode.
+ * @argument sExpr the XPath expression to use
+ * @returns the result of the XPath search as an (Sarissa)NodeList
+ * @throws An error if invoked on an HTML Element as this is only be
+ * available to XML Elements.
+ */
+ Element.prototype.selectSingleNode = function(sExpr){
+ var doc = this.ownerDocument;
+ if(doc.selectSingleNode){
+ return doc.selectSingleNode(sExpr, this);
+ }
+ else{
+ throw "Method selectNodes is only supported by XML Elements";
+ }
+ };
+ Sarissa.IS_ENABLED_SELECT_NODES = true;
+}
\ No newline at end of file
diff --git a/pacotes/cswclient/lib/xml/csw-hosts.xml b/pacotes/cswclient/lib/xml/csw-hosts.xml
new file mode 100644
index 0000000..a3bb2e8
--- /dev/null
+++ b/pacotes/cswclient/lib/xml/csw-hosts.xml
@@ -0,0 +1,8 @@
+
diff --git a/pacotes/cswclient/lib/xml/cswclient.xml b/pacotes/cswclient/lib/xml/cswclient.xml
new file mode 100644
index 0000000..f73b07b
--- /dev/null
+++ b/pacotes/cswclient/lib/xml/cswclient.xml
@@ -0,0 +1,65 @@
+