Dietrich Streifert schrieb:
Here is a better patch which does not acces the text property/attribute of nodes but implements getter methods for the text property:

This is a diff against QxXmlExtras.js in cvs renderer branch.

Is this patch usable to get committed to the qooxdoo cvs? What is the copyright stuff of this lines?

Sebastian



Dietrich Streifert schrieb:

Hello List!


if someone needs this: Gecko/Mozilla has no implementation of the simple to handle xpath node selection methods selectNodes and selectSingleNode (which are InternetExplorerer proprietary) for Element and Document object. Here is the Implementation built as patch for QxXmlExtras.


A little tutorial for the usage is:


selectNodes: http://www.webreference.com/js/tips/020309.html
selectSingleNode: http://www.webreference.com/js/tips/020310.html


------------------------------------------------------------------------

--- source/script/binding/QxXmlExtras.js.orig   2005-11-29 09:12:47.100690000 
+0100
+++ source/script/binding/QxXmlExtras.js        2005-11-29 18:44:50.191349000 
+0100
@@ -105,3 +105,60 @@
throw new Error("This browser does not support xml dom creation.");
 };
+
+// Implementation of selectNodes() and selectSingleNode()
+// for Gecko/Mozilla browsers
+if (window.XPathEvaluator) {
+
+  var xpath = new XPathEvaluator();
+
+  // if (!Element.prototype.selectSingleNode) {
+    Element.prototype.selectSingleNode = function (path) {
+      return xpath.evaluate(path, this, this.ownerDocument._ns, 
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
+    };
+  //}
+ + // if (!Element.prototype.selectNodes) {
+    Element.prototype.selectNodes = function (path) {
+      var result = xpath.evaluate(path, this, this.ownerDocument._ns, 
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+      var i, nodes = [];
+ + for (i=0; i<result.snapshotLength; i++) {
+        nodes[i] = result.snapshotItem(i);
+      };
+ + return nodes;
+    };
+  // }
+ + // if (!Document.prototype.selectSingleNode) {
+    Document.prototype.selectSingleNode = function (path) {
+      return xpath.evaluate(path, this, this._ns, 
XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
+    };
+  // }
+ + // if (!Document.prototype.selectNodes) {
+    Document.prototype.selectNodes = function (path) {
+      var result = xpath.evaluate(path, this, this._ns, 
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+      var i, nodes = [];
+
+      for (i=0; i<result.snapshotLength; i++) {
+        nodes[i] = result.snapshotItem(i);
+      };
+ + return nodes;
+    };
+  // }
+
+  Element.prototype.text getter = function(){
+               var i, a=[], nodes = this.childNodes, length = nodes.length;
+               for (i=0; i<length; i++) {
+          a[i] = nodes[i].text
+        };
+               return a.join("");
+       };
+
+  Attr.prototype.text getter = function(){return this.nodeValue};
+  Text.prototype.text getter = function(){return this.nodeValue};
+}
+



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to