You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2006/06/30 20:59:43 UTC
svn commit: r418375 - in /incubator/xap/trunk/src: google/ xap/
xap/taghandling/ xap/xml/dom/ xap/xml/dom/events/ xap/xml/xmodify/
Author: jmargaris
Date: Fri Jun 30 13:59:42 2006
New Revision: 418375
URL: http://svn.apache.org/viewvc?rev=418375&view=rev
Log:
google stuff now scoped to google.* namespace, using provides()
and requires(), etc. No more zillion top-level variables
and functions declared by google. Also removed some
methods/variables/files not in use
Added:
incubator/xap/trunk/src/google/__package__.js (with props)
Removed:
incubator/xap/trunk/src/google/dom_unittest.js
incubator/xap/trunk/src/google/xpath_unittest.js
incubator/xap/trunk/src/google/xslt.js
Modified:
incubator/xap/trunk/src/google/dom.js
incubator/xap/trunk/src/google/misc.js
incubator/xap/trunk/src/google/xpath.js
incubator/xap/trunk/src/google/xpathdebug.js
incubator/xap/trunk/src/xap/Xap.js
incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js
incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js
incubator/xap/trunk/src/xap/xml/dom/Document.js
incubator/xap/trunk/src/xap/xml/dom/XapElement.js
incubator/xap/trunk/src/xap/xml/dom/events/StructureChangeEvent.js
incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js
Added: incubator/xap/trunk/src/google/__package__.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/__package__.js?rev=418375&view=auto
==============================================================================
--- incubator/xap/trunk/src/google/__package__.js (added)
+++ incubator/xap/trunk/src/google/__package__.js Fri Jun 30 13:59:42 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+//just a test for now
+
+Xap.kwCompoundRequire({
+ common: [
+ "google.dom",
+ "google.misc",
+ "google.xpath",
+ ]
+});
+
+Xap.provide("google.*");
Propchange: incubator/xap/trunk/src/google/__package__.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/xap/trunk/src/google/dom.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/dom.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/google/dom.js (original)
+++ incubator/xap/trunk/src/google/dom.js Fri Jun 30 13:59:42 2006
@@ -12,417 +12,307 @@
//
// Author: Steffen Meschkat <me...@google.com>
-// NOTE: The split() method in IE omits empty result strings. This is
-// utterly annoying. So we don't use it here.
+Xap.require("google.misc");
+Xap.provide("google.dom");
-// Resolve entities in XML text fragments. According to the DOM
-// specification, the DOM is supposed to resolve entity references at
-// the API level. I.e. no entity references are passed through the
-// API. See "Entities and the DOM core", p.12, DOM 2 Core
-// Spec. However, different browsers actually pass very different
-// values at the API.
-//
-xmlResolveEntities = function(s) {
-
- var parts = stringSplit(s, '&');
-
- var ret = parts[0];
- for (var i = 1; i < parts.length; ++i) {
- var rp = stringSplit(parts[i], ';');
- if (rp.length == 1) {
- // no entity reference: just a & but no ;
- ret += parts[i];
- continue;
- }
-
- var ch;
- switch (rp[0]) {
- case 'lt':
- ch = '<';
- break;
- case 'gt':
- ch = '>';
- break;
- case 'amp':
- ch = '&';
- break;
- case 'quot':
- ch = '"';
- break;
- case 'apos':
- ch = '\'';
- break;
- case 'nbsp':
- ch = String.fromCharCode(160);
- break;
- default:
- // Cool trick: let the DOM do the entity decoding. We assign
- // the entity text through non-W3C DOM properties and read it
- // through the W3C DOM. W3C DOM access is specified to resolve
- // entities.
- var span = window.document.createElement('span');
- span.innerHTML = '&' + rp[0] + '; ';
- ch = span.childNodes[0].nodeValue.charAt(0);
- }
- ret += ch + rp[1];
- }
- return ret;
-}
-
-
-// Parses the given XML string with our custom, JavaScript XML parser. Written
-// by Steffen Meschkat (mesch@google.com).
-xmlParse = function(xml) {
- Timer.start('xmlparse');
- var regex_empty = /\/$/;
-
- // See also <http://www.w3.org/TR/REC-xml/#sec-common-syn> for
- // allowed chars in a tag and attribute name. TODO(mesch): the
- // following is still not completely correct.
-
- var regex_tagname = /^([\w:-]*)/;
- var regex_attribute = /([\w:-]+)\s?=\s?('([^\']*)'|"([^\"]*)")/g;
-
- var xmldoc = new XDocument();
- var root = xmldoc;
-
- // For the record: in Safari, we would create native DOM nodes, but
- // in Opera that is not possible, because the DOM only allows HTML
- // element nodes to be created, so we have to do our own DOM nodes.
-
- // xmldoc = document.implementation.createDocument('','',null);
- // root = xmldoc; // .createDocumentFragment();
- // NOTE(mesch): using the DocumentFragment instead of the Document
- // crashes my Safari 1.2.4 (v125.12).
- var stack = [];
-
- var parent = root;
- stack.push(parent);
-
- var x = stringSplit(xml, '<');
- for (var i = 1; i < x.length; ++i) {
- var xx = stringSplit(x[i], '>');
- var tag = xx[0];
- var text = xmlResolveEntities(xx[1] || '');
-
- if (tag.charAt(0) == '/') {
- stack.pop();
- parent = stack[stack.length-1];
-
- } else if (tag.charAt(0) == '?') {
- // Ignore XML declaration and processing instructions
- } else if (tag.charAt(0) == '!') {
- // Ignore notation and comments
- } else {
- var empty = tag.match(regex_empty);
- var tagname = regex_tagname.exec(tag)[1];
- var node = xmldoc.createElement(tagname);
-
- var att;
- while (att = regex_attribute.exec(tag)) {
- var val = xmlResolveEntities(att[3] || att[4] || '');
- node.setAttribute(att[1], val);
- }
-
- if (empty) {
- parent.appendChild(node);
- } else {
- parent.appendChild(node);
- parent = node;
- stack.push(node);
- }
- }
-
- if (text && parent != root) {
- parent.appendChild(xmldoc.createTextNode(text));
- }
- }
-
- Timer.end('xmlparse');
- return root;
-}
-
-
-// Our W3C DOM Node implementation. Note we call it XNode because we
+// Our W3C DOM Node implementation. Note we call it google.XNode because we
// can't define the identifier Node. We do this mostly for Opera,
// where we can't reuse the HTML DOM for parsing our own XML, and for
// Safari, where it is too expensive to have the template processor
// operate on native DOM nodes.
-XNode = function(type, name, value, owner) {
+google.XNode = function(type, name, value, owner) {
this.attributes = [];
this.childNodes = [];
- XNode.init.call(this, type, name, value, owner);
-}
-
-// Don't call as method, use apply() or call().
-XNode.init = function(type, name, value, owner) {
- this.nodeType = type - 0;
- this.nodeName = '' + name;
- this.nodeValue = '' + value;
- this.ownerDocument = owner;
-
- this.firstChild = null;
- this.lastChild = null;
- this.nextSibling = null;
- this.previousSibling = null;
- this.parentNode = null;
-}
-
-XNode.unused_ = [];
-
-XNode.recycle = function(node) {
- if (!node) {
- return;
- }
-
- if (node.constructor == XDocument) {
- XNode.recycle(node.documentElement);
- return;
- }
-
- if (node.constructor != this) {
- return;
- }
-
- XNode.unused_.push(node);
- for (var a = 0; a < node.attributes.length; ++a) {
- XNode.recycle(node.attributes[a]);
- }
- for (var c = 0; c < node.childNodes.length; ++c) {
- XNode.recycle(node.childNodes[c]);
- }
- node.attributes.length = 0;
- node.childNodes.length = 0;
- XNode.init.call(node, 0, '', '', null);
+ google.XNode.init.call(this, type, name, value, owner);
}
-XNode.create = function(type, name, value, owner) {
- if (XNode.unused_.length > 0) {
- var node = XNode.unused_.pop();
- XNode.init.call(node, type, name, value, owner);
- return node;
- } else {
- return new XNode(type, name, value, owner);
- }
-}
-
-XNode.prototype.appendChild = function(node) {
- // firstChild
- if (this.childNodes.length == 0) {
- this.firstChild = node;
- }
-
- // previousSibling
- node.previousSibling = this.lastChild;
-
- // nextSibling
- node.nextSibling = null;
- if (this.lastChild) {
- this.lastChild.nextSibling = node;
- }
-
- // parentNode
- node.parentNode = this;
-
- // lastChild
- this.lastChild = node;
-
- // childNodes
- this.childNodes.push(node);
-}
+with (google){
+ // Don't call as method, use apply() or call().
+ XNode.init = function(type, name, value, owner) {
+ this.nodeType = type - 0;
+ this.nodeName = '' + name;
+ this.nodeValue = '' + value;
+ this.ownerDocument = owner;
+
+ this.firstChild = null;
+ this.lastChild = null;
+ this.nextSibling = null;
+ this.previousSibling = null;
+ this.parentNode = null;
+ }
+
+
+ XNode.unused_ = [];
+
+ XNode.recycle = function(node) {
+ if (!node) {
+ return;
+ }
+
+ if (node.constructor == google.XDocument) {
+ XNode.recycle(node.documentElement);
+ return;
+ }
+
+ if (node.constructor != this) {
+ return;
+ }
+
+ XNode.unused_.push(node);
+ for (var a = 0; a < node.attributes.length; ++a) {
+ XNode.recycle(node.attributes[a]);
+ }
+ for (var c = 0; c < node.childNodes.length; ++c) {
+ XNode.recycle(node.childNodes[c]);
+ }
+ node.attributes.length = 0;
+ node.childNodes.length = 0;
+ XNode.init.call(node, 0, '', '', null);
+ }
+
+
+
+ XNode.create = function(type, name, value, owner) {
+ if (XNode.unused_.length > 0) {
+ var node = XNode.unused_.pop();
+ XNode.init.call(node, type, name, value, owner);
+ return node;
+ } else {
+ return new XNode(type, name, value, owner);
+ }
+ }
+
+ XNode.prototype.appendChild = function(node) {
+ // firstChild
+ if (this.childNodes.length == 0) {
+ this.firstChild = node;
+ }
+
+ // previousSibling
+ node.previousSibling = this.lastChild;
+
+ // nextSibling
+ node.nextSibling = null;
+ if (this.lastChild) {
+ this.lastChild.nextSibling = node;
+ }
+
+ // parentNode
+ node.parentNode = this;
+
+ // lastChild
+ this.lastChild = node;
+
+ // childNodes
+ this.childNodes.push(node);
+ }
+
+
+
+
+ XNode.prototype.replaceChild = function(newNode, oldNode) {
+ if (oldNode == newNode) {
+ return;
+ }
+
+ for (var i = 0; i < this.childNodes.length; ++i) {
+ if (this.childNodes[i] == oldNode) {
+ this.childNodes[i] = newNode;
+
+ var p = oldNode.parentNode;
+ oldNode.parentNode = null;
+ newNode.parentNode = p;
+
+ p = oldNode.previousSibling;
+ oldNode.previousSibling = null;
+ newNode.previousSibling = p;
+ if (newNode.previousSibling) {
+ newNode.previousSibling.nextSibling = newNode;
+ }
+
+ p = oldNode.nextSibling;
+ oldNode.nextSibling = null;
+ newNode.nextSibling = p;
+ if (newNode.nextSibling) {
+ newNode.nextSibling.previousSibling = newNode;
+ }
+
+ if (this.firstChild == oldNode) {
+ this.firstChild = newNode;
+ }
+
+ if (this.lastChild == oldNode) {
+ this.lastChild = newNode;
+ }
+
+ break;
+ }
+ }
+ }
+
+ XNode.prototype.insertBefore = function(newNode, oldNode) {
+ if (oldNode == newNode) {
+ return;
+ }
+
+ if (oldNode.parentNode != this) {
+ return;
+ }
+
+ if (newNode.parentNode) {
+ newNode.parentNode.removeChild(newNode);
+ }
+
+ var newChildren = [];
+ for (var i = 0; i < this.childNodes.length; ++i) {
+ var c = this.childNodes[i];
+ if (c == oldNode) {
+ newChildren.push(newNode);
+
+ newNode.parentNode = this;
+
+ newNode.previousSibling = oldNode.previousSibling;
+ oldNode.previousSibling = newNode;
+ if (newNode.previousSibling) {
+ newNode.previousSibling.nextSibling = newNode;
+ }
+
+ newNode.nextSibling = oldNode;
+
+ if (this.firstChild == oldNode) {
+ this.firstChild = newNode;
+ }
+ }
+ newChildren.push(c);
+ }
+ this.childNodes = newChildren;
+ }
+
+ XNode.prototype.removeChild = function(node) {
+ var newChildren = [];
+ for (var i = 0; i < this.childNodes.length; ++i) {
+ var c = this.childNodes[i];
+ if (c != node) {
+ newChildren.push(c);
+ } else {
+ if (c.previousSibling) {
+ c.previousSibling.nextSibling = c.nextSibling;
+ }
+ if (c.nextSibling) {
+ c.nextSibling.previousSibling = c.previousSibling;
+ }
+ if (this.firstChild == c) {
+ this.firstChild = c.nextSibling;
+ }
+ if (this.lastChild == c) {
+ this.lastChild = c.previousSibling;
+ }
+ }
+ }
+ this.childNodes = newChildren;
+ }
+
+
+
+ XNode.prototype.hasAttributes = function() {
+ return this.attributes.length > 0;
+ }
+
+
+ XNode.prototype.setAttribute = function(name, value) {
+ for (var i = 0; i < this.attributes.length; ++i) {
+ if (this.attributes[i].nodeName == name) {
+ this.attributes[i].nodeValue = '' + value;
+ return;
+ }
+ }
+ this.attributes.push(new XNode(DOM_ATTRIBUTE_NODE, name, value));
+ }
+
+
+ XNode.prototype.getAttribute = function(name) {
+ for (var i = 0; i < this.attributes.length; ++i) {
+ if (this.attributes[i].nodeName == name) {
+ return this.attributes[i].nodeValue;
+ }
+ }
+ return null;
+ }
+
+ XNode.prototype.removeAttribute = function(name) {
+ var a = [];
+ for (var i = 0; i < this.attributes.length; ++i) {
+ if (this.attributes[i].nodeName != name) {
+ a.push(this.attributes[i]);
+ }
+ }
+ this.attributes = a;
+ }
+
+ XNode.prototype.getElementsByTagName = function(name, list) {
+ if (!list) {
+ list = [];
+ }
+
+ if (this.nodeName == name) {
+ list.push(this);
+ }
+
+ for (var i = 0; i < this.childNodes.length; ++i) {
+ this.childNodes[i].getElementsByTagName(name, list);
+ }
+
+ return list;
+ }
-XNode.prototype.replaceChild = function(newNode, oldNode) {
- if (oldNode == newNode) {
- return;
- }
-
- for (var i = 0; i < this.childNodes.length; ++i) {
- if (this.childNodes[i] == oldNode) {
- this.childNodes[i] = newNode;
-
- var p = oldNode.parentNode;
- oldNode.parentNode = null;
- newNode.parentNode = p;
-
- p = oldNode.previousSibling;
- oldNode.previousSibling = null;
- newNode.previousSibling = p;
- if (newNode.previousSibling) {
- newNode.previousSibling.nextSibling = newNode;
- }
-
- p = oldNode.nextSibling;
- oldNode.nextSibling = null;
- newNode.nextSibling = p;
- if (newNode.nextSibling) {
- newNode.nextSibling.previousSibling = newNode;
- }
-
- if (this.firstChild == oldNode) {
- this.firstChild = newNode;
- }
-
- if (this.lastChild == oldNode) {
- this.lastChild = newNode;
- }
-
- break;
- }
- }
}
-XNode.prototype.insertBefore = function(newNode, oldNode) {
- if (oldNode == newNode) {
- return;
- }
-
- if (oldNode.parentNode != this) {
- return;
- }
-
- if (newNode.parentNode) {
- newNode.parentNode.removeChild(newNode);
- }
-
- var newChildren = [];
- for (var i = 0; i < this.childNodes.length; ++i) {
- var c = this.childNodes[i];
- if (c == oldNode) {
- newChildren.push(newNode);
-
- newNode.parentNode = this;
-
- newNode.previousSibling = oldNode.previousSibling;
- oldNode.previousSibling = newNode;
- if (newNode.previousSibling) {
- newNode.previousSibling.nextSibling = newNode;
- }
-
- newNode.nextSibling = oldNode;
-
- if (this.firstChild == oldNode) {
- this.firstChild = newNode;
- }
- }
- newChildren.push(c);
- }
- this.childNodes = newChildren;
-}
-
-XNode.prototype.removeChild = function(node) {
- var newChildren = [];
- for (var i = 0; i < this.childNodes.length; ++i) {
- var c = this.childNodes[i];
- if (c != node) {
- newChildren.push(c);
- } else {
- if (c.previousSibling) {
- c.previousSibling.nextSibling = c.nextSibling;
- }
- if (c.nextSibling) {
- c.nextSibling.previousSibling = c.previousSibling;
- }
- if (this.firstChild == c) {
- this.firstChild = c.nextSibling;
- }
- if (this.lastChild == c) {
- this.lastChild = c.previousSibling;
- }
- }
- }
- this.childNodes = newChildren;
-}
-
-
-XNode.prototype.hasAttributes = function() {
- return this.attributes.length > 0;
-}
-
-XNode.prototype.setAttribute = function(name, value) {
- for (var i = 0; i < this.attributes.length; ++i) {
- if (this.attributes[i].nodeName == name) {
- this.attributes[i].nodeValue = '' + value;
- return;
- }
- }
- this.attributes.push(new XNode(DOM_ATTRIBUTE_NODE, name, value));
-}
-
-
-XNode.prototype.getAttribute = function(name) {
- for (var i = 0; i < this.attributes.length; ++i) {
- if (this.attributes[i].nodeName == name) {
- return this.attributes[i].nodeValue;
- }
- }
- return null;
-}
-
-XNode.prototype.removeAttribute = function(name) {
- var a = [];
- for (var i = 0; i < this.attributes.length; ++i) {
- if (this.attributes[i].nodeName != name) {
- a.push(this.attributes[i]);
- }
- }
- this.attributes = a;
-}
-
-
-XDocument = function() {
- XNode.call(this, DOM_DOCUMENT_NODE, '#document', null, this);
+google.XDocument = function() {
+ google.XNode.call(this, google.DOM_DOCUMENT_NODE, '#document', null, this);
this.documentElement = null;
}
-XDocument.prototype = new XNode(DOM_DOCUMENT_NODE, '#document');
+with(google){
+
+ XDocument.prototype = new XNode(DOM_DOCUMENT_NODE, '#document');
+
+ XDocument.prototype.clear = function() {
+ XNode.recycle(this.documentElement);
+ this.documentElement = null;
+ }
+
+
+
+ XDocument.prototype.appendChild = function(node) {
+ XNode.prototype.appendChild.call(this, node);
+ this.documentElement = this.childNodes[0];
+ }
+
+ XDocument.prototype.createElement = function(name) {
+ return XNode.create(DOM_ELEMENT_NODE, name, null, this);
+ }
+
+ XDocument.prototype.createDocumentFragment = function() {
+ return XNode.create(DOM_DOCUMENT_FRAGMENT_NODE, '#document-fragment',
+ null, this);
+ }
+
+ XDocument.prototype.createTextNode = function(value) {
+ return XNode.create(DOM_TEXT_NODE, '#text', value, this);
+ }
+
+ XDocument.prototype.createAttribute = function(name) {
+ return XNode.create(DOM_ATTRIBUTE_NODE, name, null, this);
+ }
+
+ XDocument.prototype.createComment = function(data) {
+ return XNode.create(DOM_COMMENT_NODE, '#comment', data, this);
+ }
-XDocument.prototype.clear = function() {
- XNode.recycle(this.documentElement);
- this.documentElement = null;
}
-XDocument.prototype.appendChild = function(node) {
- XNode.prototype.appendChild.call(this, node);
- this.documentElement = this.childNodes[0];
-}
-XDocument.prototype.createElement = function(name) {
- return XNode.create(DOM_ELEMENT_NODE, name, null, this);
-}
-
-XDocument.prototype.createDocumentFragment = function() {
- return XNode.create(DOM_DOCUMENT_FRAGMENT_NODE, '#document-fragment',
- null, this);
-}
-
-XDocument.prototype.createTextNode = function(value) {
- return XNode.create(DOM_TEXT_NODE, '#text', value, this);
-}
-
-XDocument.prototype.createAttribute = function(name) {
- return XNode.create(DOM_ATTRIBUTE_NODE, name, null, this);
-}
-
-XDocument.prototype.createComment = function(data) {
- return XNode.create(DOM_COMMENT_NODE, '#comment', data, this);
-}
-
-XNode.prototype.getElementsByTagName = function(name, list) {
- if (!list) {
- list = [];
- }
-
- if (this.nodeName == name) {
- list.push(this);
- }
-
- for (var i = 0; i < this.childNodes.length; ++i) {
- this.childNodes[i].getElementsByTagName(name, list);
- }
-
- return list;
-}
Modified: incubator/xap/trunk/src/google/misc.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/misc.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/google/misc.js (original)
+++ incubator/xap/trunk/src/google/misc.js Fri Jun 30 13:59:42 2006
@@ -6,250 +6,220 @@
// Author: Steffen Meschkat <me...@google.com>
//
-el = function(i) {
- return document.getElementById(i);
-}
+Xap.provide("google.misc");
-px = function(x) {
- return x + 'px';
-}
-// Split a string s at all occurrences of character c. This is like
-// the split() method of the string object, but IE omits empty
-// strings, which violates the invariant (s.split(x).join(x) == s).
-stringSplit = function(s, c) {
- var a = s.indexOf(c);
- if (a == -1) {
- return [ s ];
- }
-
- var parts = [];
- parts.push(s.substr(0,a));
- while (a != -1) {
- var a1 = s.indexOf(c, a + 1);
- if (a1 != -1) {
- parts.push(s.substr(a + 1, a1 - a - 1));
- } else {
- parts.push(s.substr(a + 1));
- }
- a = a1;
- }
+with (google){
+ // Returns the text value if a node; for nodes without children this
+ // is the nodeValue, for nodes with children this is the concatenation
+ // of the value of all children.
+ google.xmlValue = function(node) {
+ if (!node) {
+ return '';
+ }
+
+ var ret = '';
+ if (node.nodeType == DOM_TEXT_NODE ||
+ node.nodeType == DOM_CDATA_SECTION_NODE ||
+ node.nodeType == DOM_ATTRIBUTE_NODE) {
+ ret += node.nodeValue;
+
+ } else if (node.nodeType == DOM_ELEMENT_NODE ||
+ node.nodeType == DOM_DOCUMENT_NODE ||
+ node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) {
+ for (var i = 0; i < node.childNodes.length; ++i) {
+ ret += arguments.callee(node.childNodes[i]);
+ }
+ }
+ return ret;
+ }
+
+ // Returns the representation of a node as XML text.
+ google.xmlText =function(node) {
+ var ret = '';
+ if (node.nodeType == DOM_TEXT_NODE) {
+ ret += xmlEscapeText(node.nodeValue);
+
+ } else if (node.nodeType == DOM_ELEMENT_NODE) {
+ ret += '<' + node.nodeName;
+ for (var i = 0; i < node.attributes.length; ++i) {
+ var a = node.attributes[i];
+ if (a && a.nodeName && a.nodeValue) {
+ ret += ' ' + a.nodeName;
+ ret += '="' + xmlEscapeAttr(a.nodeValue) + '"';
+ }
+ }
+
+ if (node.childNodes.length == 0) {
+ ret += '/>';
+
+ } else {
+ ret += '>';
+ for (var i = 0; i < node.childNodes.length; ++i) {
+ ret += arguments.callee(node.childNodes[i]);
+ }
+ ret += '</' + node.nodeName + '>';
+ }
+
+ } else if (node.nodeType == DOM_DOCUMENT_NODE ||
+ node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) {
+ for (var i = 0; i < node.childNodes.length; ++i) {
+ ret += arguments.callee(node.childNodes[i]);
+ }
+ }
+
+ return ret;
+ }
+
+ // Applies the given function to each element of the array.
+ google.mapExec = function(array, func) {
+ for (var i = 0; i < array.length; ++i) {
+ func(array[i]);
+ }
+ }
+
+ // Returns an array that contains the return value of the given
+ // function applied to every element of the input array.
+ google.mapExpr = function(array, func) {
+ var ret = [];
+ for (var i = 0; i < array.length; ++i) {
+ ret.push(func(array[i]));
+ }
+ return ret;
+ };
+
+ // Reverses the given array in place.
+ google.reverseInplace = function(array) {
+ for (var i = 0; i < array.length / 2; ++i) {
+ var h = array[i];
+ var ii = array.length - i - 1;
+ array[i] = array[ii];
+ array[ii] = h;
+ }
+ }
+
+ // Shallow-copies an array.
+ google.copyArray = function(dst, src) {
+ for (var i = 0; i < src.length; ++i) {
+ dst.push(src[i]);
+ }
+ }
+
+ google.assert = function(b) {
+ if (!b) {
+ throw 'assertion failed';
+ }
+ }
+
+
+ // Based on
+ // <http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247>
+ google.DOM_ELEMENT_NODE = 1;
+ google.DOM_ATTRIBUTE_NODE = 2;
+ google.DOM_TEXT_NODE = 3;
+ google.DOM_CDATA_SECTION_NODE = 4;
+ google.DOM_ENTITY_REFERENCE_NODE = 5;
+ google.DOM_ENTITY_NODE = 6;
+ google.DOM_PROCESSING_INSTRUCTION_NODE = 7;
+ google.DOM_COMMENT_NODE = 8;
+ google.DOM_DOCUMENT_NODE = 9;
+ google.DOM_DOCUMENT_TYPE_NODE = 10;
+ google.DOM_DOCUMENT_FRAGMENT_NODE = 11;
+ google.DOM_NOTATION_NODE = 12;
+
+
+ google.xpathdebug = false; // trace xpath parsing
+ google.xsltdebug = false; // trace xslt processing
+
+
+ // Escape XML special markup chracters: tag delimiter < > and entity
+ // reference start delimiter &. The escaped string can be used in XML
+ // text portions (i.e. between tags).
+ google.xmlEscapeText = function(s) {
+ return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
+ }
+
+ // Escape XML special markup characters: tag delimiter < > entity
+ // reference start delimiter & and quotes ". The escaped string can be
+ // used in double quoted XML attribute value portions (i.e. in
+ // attributes within start tags).
+ google.xmlEscapeAttr = function(s) {
+ return xmlEscapeText(s).replace(/\"/g, '"');
+ }
+
+ // Escape markup in XML text, but don't touch entity references. The
+ // escaped string can be used as XML text (i.e. between tags).
+ google.xmlEscapeTags = function(s) {
+ return s.replace(/</g, '<').replace(/>/g, '>');
+ }
+
+ // An implementation of the debug log.
+
+ google.logging__ = true;
+
+ google.Log = function() {};
+
+ Log.lines = [];
+
+ Log.write = function(s) {
+ if (logging__) {
+ this.lines.push(xmlEscapeText(s));
+ this.show();
+ }
+ };
+
+ // Writes the given XML with every tag on a new line.
+ Log.writeXML = function(xml) {
+ if (logging__) {
+ var s0 = xml.replace(/</g, '\n<');
+ var s1 = xmlEscapeText(s0);
+ var s2 = s1.replace(/\s*\n(\s|\n)*/g, '<br/>');
+ this.lines.push(s2);
+ this.show();
+ }
+ }
+
+ // Writes without any escaping
+ Log.writeRaw = function(s) {
+ if (logging__) {
+ this.lines.push(s);
+ this.show();
+ }
+ }
+
+ Log.clear = function() {
+ if (logging__) {
+ var l = this.div();
+ l.innerHTML = '';
+ this.lines = [];
+ }
+ }
+
+ Log.show = function() {
+ var l = this.div();
+ l.innerHTML += this.lines.join('<br/>') + '<br/>';
+ this.lines = [];
+ l.scrollTop = l.scrollHeight;
+ }
+
+ Log.div = function() {
+ var l = document.getElementById('log');
+ if (!l) {
+ l = document.createElement('div');
+ l.id = 'log';
+ l.style.position = 'absolute';
+ l.style.right = '5px';
+ l.style.top = '5px';
+ l.style.width = '250px';
+ l.style.height = '150px';
+ l.style.overflow = 'auto';
+ l.style.backgroundColor = '#f0f0f0';
+ l.style.border = '1px solid gray';
+ l.style.fontSize = '10px';
+ l.style.padding = '5px';
+ document.body.appendChild(l);
+ }
+ return l;
+ }
- return parts;
-}
-
-// Returns the text value if a node; for nodes without children this
-// is the nodeValue, for nodes with children this is the concatenation
-// of the value of all children.
-xmlValue = function(node) {
- if (!node) {
- return '';
- }
-
- var ret = '';
- if (node.nodeType == DOM_TEXT_NODE ||
- node.nodeType == DOM_CDATA_SECTION_NODE ||
- node.nodeType == DOM_ATTRIBUTE_NODE) {
- ret += node.nodeValue;
-
- } else if (node.nodeType == DOM_ELEMENT_NODE ||
- node.nodeType == DOM_DOCUMENT_NODE ||
- node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) {
- for (var i = 0; i < node.childNodes.length; ++i) {
- ret += arguments.callee(node.childNodes[i]);
- }
- }
- return ret;
-}
-
-// Returns the representation of a node as XML text.
-xmlText =function(node) {
- var ret = '';
- if (node.nodeType == DOM_TEXT_NODE) {
- ret += xmlEscapeText(node.nodeValue);
-
- } else if (node.nodeType == DOM_ELEMENT_NODE) {
- ret += '<' + node.nodeName;
- for (var i = 0; i < node.attributes.length; ++i) {
- var a = node.attributes[i];
- if (a && a.nodeName && a.nodeValue) {
- ret += ' ' + a.nodeName;
- ret += '="' + xmlEscapeAttr(a.nodeValue) + '"';
- }
- }
-
- if (node.childNodes.length == 0) {
- ret += '/>';
-
- } else {
- ret += '>';
- for (var i = 0; i < node.childNodes.length; ++i) {
- ret += arguments.callee(node.childNodes[i]);
- }
- ret += '</' + node.nodeName + '>';
- }
-
- } else if (node.nodeType == DOM_DOCUMENT_NODE ||
- node.nodeType == DOM_DOCUMENT_FRAGMENT_NODE) {
- for (var i = 0; i < node.childNodes.length; ++i) {
- ret += arguments.callee(node.childNodes[i]);
- }
- }
-
- return ret;
-}
-
-// Applies the given function to each element of the array.
-mapExec = function(array, func) {
- for (var i = 0; i < array.length; ++i) {
- func(array[i]);
- }
-}
-
-// Returns an array that contains the return value of the given
-// function applied to every element of the input array.
-mapExpr = function(array, func) {
- var ret = [];
- for (var i = 0; i < array.length; ++i) {
- ret.push(func(array[i]));
- }
- return ret;
-};
-
-// Reverses the given array in place.
-reverseInplace = function(array) {
- for (var i = 0; i < array.length / 2; ++i) {
- var h = array[i];
- var ii = array.length - i - 1;
- array[i] = array[ii];
- array[ii] = h;
- }
-}
-
-// Shallow-copies an array.
-copyArray = function(dst, src) {
- for (var i = 0; i < src.length; ++i) {
- dst.push(src[i]);
- }
-}
-
-assert = function(b) {
- if (!b) {
- throw 'assertion failed';
- }
-}
-
-// Based on
-// <http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247>
-DOM_ELEMENT_NODE = 1;
-DOM_ATTRIBUTE_NODE = 2;
-DOM_TEXT_NODE = 3;
-DOM_CDATA_SECTION_NODE = 4;
-DOM_ENTITY_REFERENCE_NODE = 5;
-DOM_ENTITY_NODE = 6;
-DOM_PROCESSING_INSTRUCTION_NODE = 7;
-DOM_COMMENT_NODE = 8;
-DOM_DOCUMENT_NODE = 9;
-DOM_DOCUMENT_TYPE_NODE = 10;
-DOM_DOCUMENT_FRAGMENT_NODE = 11;
-DOM_NOTATION_NODE = 12;
-
-
-xpathdebug = false; // trace xpath parsing
-xsltdebug = false; // trace xslt processing
-
-
-// Escape XML special markup chracters: tag delimiter < > and entity
-// reference start delimiter &. The escaped string can be used in XML
-// text portions (i.e. between tags).
-xmlEscapeText = function(s) {
- return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
-}
-
-// Escape XML special markup characters: tag delimiter < > entity
-// reference start delimiter & and quotes ". The escaped string can be
-// used in double quoted XML attribute value portions (i.e. in
-// attributes within start tags).
-xmlEscapeAttr = function(s) {
- return xmlEscapeText(s).replace(/\"/g, '"');
-}
-
-// Escape markup in XML text, but don't touch entity references. The
-// escaped string can be used as XML text (i.e. between tags).
-xmlEscapeTags = function(s) {
- return s.replace(/</g, '<').replace(/>/g, '>');
-}
-
-// An implementation of the debug log.
-
-logging__ = true;
-
-Log = function() {};
-
-Log.lines = [];
-
-Log.write = function(s) {
- if (logging__) {
- this.lines.push(xmlEscapeText(s));
- this.show();
- }
-};
-
-// Writes the given XML with every tag on a new line.
-Log.writeXML = function(xml) {
- if (logging__) {
- var s0 = xml.replace(/</g, '\n<');
- var s1 = xmlEscapeText(s0);
- var s2 = s1.replace(/\s*\n(\s|\n)*/g, '<br/>');
- this.lines.push(s2);
- this.show();
- }
-}
-
-// Writes without any escaping
-Log.writeRaw = function(s) {
- if (logging__) {
- this.lines.push(s);
- this.show();
- }
-}
-
-Log.clear = function() {
- if (logging__) {
- var l = this.div();
- l.innerHTML = '';
- this.lines = [];
- }
-}
-
-Log.show = function() {
- var l = this.div();
- l.innerHTML += this.lines.join('<br/>') + '<br/>';
- this.lines = [];
- l.scrollTop = l.scrollHeight;
-}
-
-Log.div = function() {
- var l = document.getElementById('log');
- if (!l) {
- l = document.createElement('div');
- l.id = 'log';
- l.style.position = 'absolute';
- l.style.right = '5px';
- l.style.top = '5px';
- l.style.width = '250px';
- l.style.height = '150px';
- l.style.overflow = 'auto';
- l.style.backgroundColor = '#f0f0f0';
- l.style.border = '1px solid gray';
- l.style.fontSize = '10px';
- l.style.padding = '5px';
- document.body.appendChild(l);
- }
- return l;
-}
-
-
-Timer = function() {}
-Timer.start = function() {}
-Timer.end = function() {}
+}
\ No newline at end of file
Modified: incubator/xap/trunk/src/google/xpath.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/xpath.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/google/xpath.js (original)
+++ incubator/xap/trunk/src/google/xpath.js Fri Jun 30 13:59:42 2006
@@ -37,13 +37,20 @@
// Author: Steffen Meschkat <me...@google.com>
+Xap.require("google.misc");
+Xap.require("google.dom");
+Xap.provide("google.xpath");
+
// The entry point for the parser.
//
// @param expr a string that contains an XPath expression.
// @return an expression object that can be evaluated with an
// expression context.
-xpathParse = function(expr) {
+
+with(google){
+
+google.xpathParse = function(expr) {
if (xpathdebug) {
Log.write('XPath parse ' + expr);
}
@@ -82,9 +89,6 @@
}
var cachekey = expr; // expr is modified during parse
- if (xpathdebug) {
- Timer.start('XPath parse', cachekey);
- }
var stack = [];
var ahead = null;
@@ -180,10 +184,6 @@
xpathParseCache[cachekey] = result;
if (xpathdebug) {
- Timer.end('XPath parse', cachekey);
- }
-
- if (xpathdebug) {
Log.write('XPath parse: ' + parse_count + ' / ' +
lexer_count + ' / ' + reduce_count);
}
@@ -193,11 +193,11 @@
xpathParseCache = {};
-xpathCacheLookup = function(expr) {
+google.xpathCacheLookup = function(expr) {
return xpathParseCache[expr];
}
-xpathReduce = function(stack, ahead) {
+google.xpathReduce = function(stack, ahead) {
var cand = null;
if (stack.length > 0) {
@@ -256,7 +256,7 @@
return ret;
}
-xpathMatchStack = function(stack, pattern) {
+google.xpathMatchStack = function(stack, pattern) {
// NOTE(mesch): The stack matches for variable cardinality are
// greedy but don't do backtracking. This would be an issue only
@@ -328,11 +328,11 @@
}
}
-xpathTokenPrecedence = function(tag) {
+google.xpathTokenPrecedence = function(tag) {
return tag.prec || 2;
}
-xpathGrammarPrecedence = function(frame) {
+google.xpathGrammarPrecedence = function(frame) {
var ret = 0;
if (frame.rule) { /* normal reduce */
@@ -358,7 +358,7 @@
return ret;
}
-stackToString = function(stack) {
+google.stackToString = function(stack) {
var ret = '';
for (var i = 0; i < stack.length; ++i) {
if (ret) {
@@ -403,7 +403,7 @@
// variables in XPath. (A variable is visible to all subsequent
// siblings, not only to its children.)
-ExprContext = function(node, position, nodelist, parent) {
+google.ExprContext = function(node, position, nodelist, parent) {
this.node = node;
this.position = position || 0;
this.nodelist = nodelist || [ node ];
@@ -474,7 +474,7 @@
// Node objects.
//
-StringValue = function(value) {
+google.StringValue = function(value) {
this.value = value;
this.type = 'string';
}
@@ -495,7 +495,7 @@
throw this + ' ' + Error().stack;
}
-BooleanValue = function(value) {
+google.BooleanValue = function(value) {
this.value = value;
this.type = 'boolean';
}
@@ -516,7 +516,7 @@
throw this + ' ' + Error().stack;
}
-NumberValue = function(value) {
+google.NumberValue = function(value) {
this.value = value;
this.type = 'number';
}
@@ -537,7 +537,7 @@
throw this + ' ' + Error().stack;
}
-NodeSetValue = function(value) {
+google.NodeSetValue = function(value) {
this.value = value;
this.type = 'node-set';
}
@@ -579,7 +579,7 @@
// parseTree(indent) -- returns a parse tree representation of the
// expression (defined in xsltdebug.js).
-TokenExpr = function(m) {
+google.TokenExpr = function(m) {
this.value = m;
}
@@ -587,7 +587,7 @@
return new StringValue(this.value);
};
-LocationExpr = function() {
+google.LocationExpr = function() {
this.absolute = false;
this.steps = [];
}
@@ -618,7 +618,7 @@
return new NodeSetValue(nodes);
};
-xPathStep = function(nodes, steps, step, input, ctx) {
+google.xPathStep = function(nodes, steps, step, input, ctx) {
var s = steps[step];
var ctx2 = ctx.clone(input);
var nodelist = s.evaluate(ctx2).nodeSetValue();
@@ -632,7 +632,7 @@
}
}
-StepExpr = function(axis, nodetest, predicate) {
+google.StepExpr = function(axis, nodetest, predicate) {
this.axis = axis;
this.nodetest = nodetest;
this.predicate = predicate || [];
@@ -740,7 +740,7 @@
return new NodeSetValue(nodelist);
};
-NodeTestAny = function() {
+google.NodeTestAny = function() {
this.value = new BooleanValue(true);
}
@@ -748,25 +748,25 @@
return this.value;
};
-NodeTestElement = function() {}
+google.NodeTestElement = function() {}
NodeTestElement.prototype.evaluate = function(ctx) {
return new BooleanValue(ctx.node.nodeType == DOM_ELEMENT_NODE);
}
-NodeTestText = function() {}
+google.NodeTestText = function() {}
NodeTestText.prototype.evaluate = function(ctx) {
return new BooleanValue(ctx.node.nodeType == DOM_TEXT_NODE);
}
-NodeTestComment = function() {}
+google.NodeTestComment = function() {}
NodeTestComment.prototype.evaluate = function(ctx) {
return new BooleanValue(ctx.node.nodeType == DOM_COMMENT_NODE);
}
-NodeTestPI = function(target) {
+google.NodeTestPI = function(target) {
this.target = target;
}
@@ -776,7 +776,7 @@
(!this.target || ctx.node.nodeName == this.target));
}
-NodeTestNC = function(nsprefix) {
+google.NodeTestNC = function(nsprefix) {
this.regex = new RegExp("^" + nsprefix + ":");
this.nsprefix = nsprefix;
}
@@ -786,7 +786,7 @@
return new BooleanValue(this.regex.match(n.nodeName));
}
-NodeTestName = function(name) {
+google.NodeTestName = function(name) {
this.name = name;
}
@@ -795,7 +795,7 @@
return new BooleanValue(n.nodeName == this.name);
}
-PredicateExpr = function(expr) {
+google.PredicateExpr = function(expr) {
this.expr = expr;
}
@@ -811,7 +811,7 @@
}
};
-FunctionCallExpr = function(name) {
+google.FunctionCallExpr = function(name) {
this.name = name;
this.args = [];
}
@@ -1148,7 +1148,7 @@
}
};
-UnionExpr = function(expr1, expr2) {
+google.UnionExpr = function(expr1, expr2) {
this.expr1 = expr1;
this.expr2 = expr2;
}
@@ -1170,7 +1170,7 @@
return new NodeSetValue(nodes2);
};
-PathExpr = function(filter, rel) {
+google.PathExpr = function(filter, rel) {
this.filter = filter;
this.rel = rel;
}
@@ -1187,7 +1187,7 @@
return new NodeSetValue(nodes1);
};
-FilterExpr = function(expr, predicate) {
+google.FilterExpr = function(expr, predicate) {
this.expr = expr;
this.predicate = predicate;
}
@@ -1208,7 +1208,7 @@
return new NodeSetValue(nodes);
}
-UnaryMinusExpr = function(expr) {
+google.UnaryMinusExpr = function(expr) {
this.expr = expr;
}
@@ -1216,7 +1216,7 @@
return new NumberValue(-this.expr.evaluate(ctx).numberValue());
};
-BinaryExpr = function(expr1, op, expr2) {
+google.BinaryExpr = function(expr1, op, expr2) {
this.expr1 = expr1;
this.expr2 = expr2;
this.op = op;
@@ -1382,7 +1382,7 @@
return new BooleanValue(ret);
}
-LiteralExpr = function(value) {
+google.LiteralExpr = function(value) {
this.value = value;
}
@@ -1390,7 +1390,7 @@
return new StringValue(this.value);
};
-NumberExpr = function(value) {
+google.NumberExpr = function(value) {
this.value = value;
}
@@ -1398,7 +1398,7 @@
return new NumberValue(this.value);
};
-VariableExpr = function(name) {
+google.VariableExpr = function(name) {
this.name = name;
}
@@ -1415,81 +1415,81 @@
// expression in an actual context. These factory functions are used
// in the specification of the grammar rules, below.
-makeTokenExpr = function(m) {
+google.makeTokenExpr = function(m) {
return new TokenExpr(m);
}
-passExpr = function(e) {
+google.passExpr = function(e) {
return e;
}
-makeLocationExpr1 = function(slash, rel) {
+google.makeLocationExpr1 = function(slash, rel) {
rel.absolute = true;
return rel;
}
-makeLocationExpr2 = function(dslash, rel) {
+google.makeLocationExpr2 = function(dslash, rel) {
rel.absolute = true;
rel.prependStep(makeAbbrevStep(dslash.value));
return rel;
}
-makeLocationExpr3 = function(slash) {
+google.makeLocationExpr3 = function(slash) {
var ret = new LocationExpr();
ret.appendStep(makeAbbrevStep('.'));
ret.absolute = true;
return ret;
}
-makeLocationExpr4 = function(dslash) {
+google.makeLocationExpr4 = function(dslash) {
var ret = new LocationExpr();
ret.absolute = true;
ret.appendStep(makeAbbrevStep(dslash.value));
return ret;
}
-makeLocationExpr5 = function(step) {
+google.makeLocationExpr5 = function(step) {
var ret = new LocationExpr();
ret.appendStep(step);
return ret;
}
-makeLocationExpr6 = function(rel, slash, step) {
+google.makeLocationExpr6 = function(rel, slash, step) {
rel.appendStep(step);
return rel;
}
-makeLocationExpr7 = function(rel, dslash, step) {
+google.makeLocationExpr7 = function(rel, dslash, step) {
rel.appendStep(makeAbbrevStep(dslash.value));
return rel;
}
-makeStepExpr1 = function(dot) {
+google.makeStepExpr1 = function(dot) {
return makeAbbrevStep(dot.value);
}
-makeStepExpr2 = function(ddot) {
+google.makeStepExpr2 = function(ddot) {
return makeAbbrevStep(ddot.value);
}
-makeStepExpr3 = function(axisname, axis, nodetest) {
+google.makeStepExpr3 = function(axisname, axis, nodetest) {
return new StepExpr(axisname.value, nodetest);
}
-makeStepExpr4 = function(at, nodetest) {
+google.makeStepExpr4 = function(at, nodetest) {
return new StepExpr('attribute', nodetest);
}
-makeStepExpr5 = function(nodetest) {
+google.makeStepExpr5 = function(nodetest) {
return new StepExpr('child', nodetest);
}
-makeStepExpr6 = function(step, predicate) {
+google.makeStepExpr6 = function(step, predicate) {
step.appendPredicate(predicate);
return step;
}
-makeAbbrevStep = function(abbrev) {
+google.makeAbbrevStep = function(abbrev) {
switch (abbrev) {
case '//':
return new StepExpr('descendant-or-self', new NodeTestAny);
@@ -1502,19 +1502,19 @@
}
}
-makeNodeTestExpr1 = function(asterisk) {
+google.makeNodeTestExpr1 = function(asterisk) {
return new NodeTestElement;
}
-makeNodeTestExpr2 = function(ncname, colon, asterisk) {
+google.makeNodeTestExpr2 = function(ncname, colon, asterisk) {
return new NodeTestNC(ncname.value);
}
-makeNodeTestExpr3 = function(qname) {
+google.makeNodeTestExpr3 = function(qname) {
return new NodeTestName(qname.value);
}
-makeNodeTestExpr4 = function(typeo, parenc) {
+google.makeNodeTestExpr4 = function(typeo, parenc) {
var type = typeo.value.replace(/\s*\($/, '');
switch(type) {
case 'node':
@@ -1531,7 +1531,7 @@
}
}
-makeNodeTestExpr5 = function(typeo, target, parenc) {
+google.makeNodeTestExpr5 = function(typeo, target, parenc) {
var type = typeo.replace(/\s*\($/, '');
if (type != 'processing-instruction') {
throw type + ' ' + Error().stack;
@@ -1539,19 +1539,19 @@
return new NodeTestPI(target.value);
}
-makePredicateExpr = function(pareno, expr, parenc) {
+google.makePredicateExpr = function(pareno, expr, parenc) {
return new PredicateExpr(expr);
}
-makePrimaryExpr = function(pareno, expr, parenc) {
+google.makePrimaryExpr = function(pareno, expr, parenc) {
return expr;
}
-makeFunctionCallExpr1 = function(name, pareno, parenc) {
+google.makeFunctionCallExpr1 = function(name, pareno, parenc) {
return new FunctionCallExpr(name);
}
-makeFunctionCallExpr2 = function(name, pareno, arg1, args, parenc) {
+google.makeFunctionCallExpr2 = function(name, pareno, arg1, args, parenc) {
var ret = new FunctionCallExpr(name);
ret.appendArg(arg1);
for (var i = 0; i < args.length; ++i) {
@@ -1560,24 +1560,24 @@
return ret;
}
-makeArgumentExpr = function(comma, expr) {
+google.makeArgumentExpr = function(comma, expr) {
return expr;
}
-makeUnionExpr = function(expr1, pipe, expr2) {
+google.makeUnionExpr = function(expr1, pipe, expr2) {
return new UnionExpr(expr1, expr2);
}
-makePathExpr1 = function(filter, slash, rel) {
+google.makePathExpr1 = function(filter, slash, rel) {
return new PathExpr(filter, rel);
}
-makePathExpr2 = function(filter, dslash, rel) {
+google.makePathExpr2 = function(filter, dslash, rel) {
rel.prependStep(makeAbbrevStep(dslash.value));
return new PathExpr(filter, rel);
}
-makeFilterExpr = function(expr, predicates) {
+google.makeFilterExpr = function(expr, predicates) {
if (predicates.length > 0) {
return new FilterExpr(expr, predicates);
} else {
@@ -1585,31 +1585,31 @@
}
}
-makeUnaryMinusExpr = function(minus, expr) {
+google.makeUnaryMinusExpr = function(minus, expr) {
return new UnaryMinusExpr(expr);
}
-makeBinaryExpr = function(expr1, op, expr2) {
+google.makeBinaryExpr = function(expr1, op, expr2) {
return new BinaryExpr(expr1, op, expr2);
}
-makeLiteralExpr = function(token) {
+google.makeLiteralExpr = function(token) {
// remove quotes from the parsed value:
var value = token.value.substring(1, token.value.length - 1);
return new LiteralExpr(value);
}
-makeNumberExpr = function(token) {
+google.makeNumberExpr = function(token) {
return new NumberExpr(token.value);
}
-makeVariableReference = function(dollar, name) {
+google.makeVariableReference = function(dollar, name) {
return new VariableExpr(name.value);
}
// Used before parsing for optimization of common simple cases. See
// the begin of xpathParse() for which they are.
-makeSimpleExpr = function(expr) {
+google.makeSimpleExpr = function(expr) {
if (expr.charAt(0) == '$') {
return new VariableExpr(expr.substr(1));
} else if (expr.charAt(0) == '@') {
@@ -1629,7 +1629,7 @@
}
}
-makeSimpleExpr2 = function(expr) {
+google.makeSimpleExpr2 = function(expr) {
var steps = expr.split('/');
var c = new LocationExpr();
for (var i in steps) {
@@ -1642,7 +1642,7 @@
// The axes of XPath expressions.
-xpathAxis = {
+google.xpathAxis = {
ANCESTOR_OR_SELF: 'ancestor-or-self',
ANCESTOR: 'ancestor',
ATTRIBUTE: 'attribute',
@@ -1658,7 +1658,7 @@
SELF: 'self'
};
-xpathAxesRe = [
+google.xpathAxesRe = [
xpathAxis.ANCESTOR_OR_SELF,
xpathAxis.ANCESTOR,
xpathAxis.ATTRIBUTE,
@@ -1684,58 +1684,58 @@
// NOTE: tabular formatting is the big exception, but here it should
// be OK.
-TOK_PIPE = { label: "|", prec: 17, re: new RegExp("^\\|") };
-TOK_DSLASH = { label: "//", prec: 19, re: new RegExp("^//") };
-TOK_SLASH = { label: "/", prec: 30, re: new RegExp("^/") };
-TOK_AXIS = { label: "::", prec: 20, re: new RegExp("^::") };
-TOK_COLON = { label: ":", prec: 1000, re: new RegExp("^:") };
-TOK_AXISNAME = { label: "[axis]", re: new RegExp('^(' + xpathAxesRe + ')') };
-TOK_PARENO = { label: "(", prec: 34, re: new RegExp("^\\(") };
-TOK_PARENC = { label: ")", re: new RegExp("^\\)") };
-TOK_DDOT = { label: "..", prec: 34, re: new RegExp("^\\.\\.") };
-TOK_DOT = { label: ".", prec: 34, re: new RegExp("^\\.") };
-TOK_AT = { label: "@", prec: 34, re: new RegExp("^@") };
-
-TOK_COMMA = { label: ",", re: new RegExp("^,") };
-
-TOK_OR = { label: "or", prec: 10, re: new RegExp("^or\\b") };
-TOK_AND = { label: "and", prec: 11, re: new RegExp("^and\\b") };
-TOK_EQ = { label: "=", prec: 12, re: new RegExp("^=") };
-TOK_NEQ = { label: "!=", prec: 12, re: new RegExp("^!=") };
-TOK_GE = { label: ">=", prec: 13, re: new RegExp("^>=") };
-TOK_GT = { label: ">", prec: 13, re: new RegExp("^>") };
-TOK_LE = { label: "<=", prec: 13, re: new RegExp("^<=") };
-TOK_LT = { label: "<", prec: 13, re: new RegExp("^<") };
-TOK_PLUS = { label: "+", prec: 14, re: new RegExp("^\\+"), left: true };
-TOK_MINUS = { label: "-", prec: 14, re: new RegExp("^\\-"), left: true };
-TOK_DIV = { label: "div", prec: 15, re: new RegExp("^div\\b"), left: true };
-TOK_MOD = { label: "mod", prec: 15, re: new RegExp("^mod\\b"), left: true };
-
-TOK_BRACKO = { label: "[", prec: 32, re: new RegExp("^\\[") };
-TOK_BRACKC = { label: "]", re: new RegExp("^\\]") };
-TOK_DOLLAR = { label: "$", re: new RegExp("^\\$") };
-
-TOK_NCNAME = { label: "[ncname]", re: new RegExp('^[a-z][-\\w]*','i') };
-
-TOK_ASTERISK = { label: "*", prec: 15, re: new RegExp("^\\*"), left: true };
-TOK_LITERALQ = { label: "[litq]", prec: 20, re: new RegExp("^'[^\\']*'") };
-TOK_LITERALQQ = {
+google.TOK_PIPE = { label: "|", prec: 17, re: new RegExp("^\\|") };
+google.TOK_DSLASH = { label: "//", prec: 19, re: new RegExp("^//") };
+google.TOK_SLASH = { label: "/", prec: 30, re: new RegExp("^/") };
+google.TOK_AXIS = { label: "::", prec: 20, re: new RegExp("^::") };
+google.TOK_COLON = { label: ":", prec: 1000, re: new RegExp("^:") };
+google.TOK_AXISNAME = { label: "[axis]", re: new RegExp('^(' + xpathAxesRe + ')') };
+google.TOK_PARENO = { label: "(", prec: 34, re: new RegExp("^\\(") };
+google.TOK_PARENC = { label: ")", re: new RegExp("^\\)") };
+google.TOK_DDOT = { label: "..", prec: 34, re: new RegExp("^\\.\\.") };
+google.TOK_DOT = { label: ".", prec: 34, re: new RegExp("^\\.") };
+google.TOK_AT = { label: "@", prec: 34, re: new RegExp("^@") };
+
+google.TOK_COMMA = { label: ",", re: new RegExp("^,") };
+
+google.TOK_OR = { label: "or", prec: 10, re: new RegExp("^or\\b") };
+google.TOK_AND = { label: "and", prec: 11, re: new RegExp("^and\\b") };
+google.TOK_EQ = { label: "=", prec: 12, re: new RegExp("^=") };
+google.TOK_NEQ = { label: "!=", prec: 12, re: new RegExp("^!=") };
+google.TOK_GE = { label: ">=", prec: 13, re: new RegExp("^>=") };
+google.TOK_GT = { label: ">", prec: 13, re: new RegExp("^>") };
+google.TOK_LE = { label: "<=", prec: 13, re: new RegExp("^<=") };
+google.TOK_LT = { label: "<", prec: 13, re: new RegExp("^<") };
+google.TOK_PLUS = { label: "+", prec: 14, re: new RegExp("^\\+"), left: true };
+google.TOK_MINUS = { label: "-", prec: 14, re: new RegExp("^\\-"), left: true };
+google.TOK_DIV = { label: "div", prec: 15, re: new RegExp("^div\\b"), left: true };
+google.TOK_MOD = { label: "mod", prec: 15, re: new RegExp("^mod\\b"), left: true };
+
+google.TOK_BRACKO = { label: "[", prec: 32, re: new RegExp("^\\[") };
+google.TOK_BRACKC = { label: "]", re: new RegExp("^\\]") };
+google.TOK_DOLLAR = { label: "$", re: new RegExp("^\\$") };
+
+google.TOK_NCNAME = { label: "[ncname]", re: new RegExp('^[a-z][-\\w]*','i') };
+
+google.TOK_ASTERISK = { label: "*", prec: 15, re: new RegExp("^\\*"), left: true };
+google.TOK_LITERALQ = { label: "[litq]", prec: 20, re: new RegExp("^'[^\\']*'") };
+google.TOK_LITERALQQ = {
label: "[litqq]",
prec: 20,
re: new RegExp('^"[^\\"]*"')
};
-TOK_NUMBER = {
+google.TOK_NUMBER = {
label: "[number]",
prec: 35,
re: new RegExp('^\\d+(\\.\\d*)?') };
-TOK_QNAME = {
+google.TOK_QNAME = {
label: "[qname]",
re: new RegExp('^([a-z][-\\w]*:)?[a-z][-\\w]*','i')
};
-TOK_NODEO = {
+google.TOK_NODEO = {
label: "[nodetest-start]",
re: new RegExp('^(processing-instruction|comment|text|node)\\(')
};
@@ -1748,7 +1748,7 @@
// NOTE: order of this list is important, because the first match
// counts. Cf. DDOT and DOT, and AXIS and COLON.
-xpathTokenRules = [
+google.xpathTokenRules = [
TOK_DSLASH,
TOK_SLASH,
TOK_DDOT,
@@ -1788,25 +1788,25 @@
// All the nonterminals of the grammar. The nonterminal objects are
// identified by object identity; the labels are used in the debug
// output only.
-XPathLocationPath = { label: "LocationPath" };
-XPathRelativeLocationPath = { label: "RelativeLocationPath" };
-XPathAbsoluteLocationPath = { label: "AbsoluteLocationPath" };
-XPathStep = { label: "Step" };
-XPathNodeTest = { label: "NodeTest" };
-XPathPredicate = { label: "Predicate" };
-XPathLiteral = { label: "Literal" };
-XPathExpr = { label: "Expr" };
-XPathPrimaryExpr = { label: "PrimaryExpr" };
-XPathVariableReference = { label: "Variablereference" };
-XPathNumber = { label: "Number" };
-XPathFunctionCall = { label: "FunctionCall" };
-XPathArgumentRemainder = { label: "ArgumentRemainder" };
-XPathPathExpr = { label: "PathExpr" };
-XPathUnionExpr = { label: "UnionExpr" };
-XPathFilterExpr = { label: "FilterExpr" };
-XPathDigits = { label: "Digits" };
+google.XPathLocationPath = { label: "LocationPath" };
+google.XPathRelativeLocationPath = { label: "RelativeLocationPath" };
+google.XPathAbsoluteLocationPath = { label: "AbsoluteLocationPath" };
+google.XPathStep = { label: "Step" };
+google.XPathNodeTest = { label: "NodeTest" };
+google.XPathPredicate = { label: "Predicate" };
+google.XPathLiteral = { label: "Literal" };
+google.XPathExpr = { label: "Expr" };
+google.XPathPrimaryExpr = { label: "PrimaryExpr" };
+google.XPathVariableReference = { label: "Variablereference" };
+google.XPathNumber = { label: "Number" };
+google.XPathFunctionCall = { label: "FunctionCall" };
+google.XPathArgumentRemainder = { label: "ArgumentRemainder" };
+google.XPathPathExpr = { label: "PathExpr" };
+google.XPathUnionExpr = { label: "UnionExpr" };
+google.XPathFilterExpr = { label: "FilterExpr" };
+google.XPathDigits = { label: "Digits" };
-xpathNonTerminals = [
+google.xpathNonTerminals = [
XPathLocationPath,
XPathRelativeLocationPath,
XPathAbsoluteLocationPath,
@@ -1827,12 +1827,12 @@
];
// Quantifiers that are used in the productions of the grammar.
-Q_01 = { label: "?" };
-Q_MM = { label: "*" };
-Q_1M = { label: "+" };
+google.Q_01 = { label: "?" };
+google.Q_MM = { label: "*" };
+google.Q_1M = { label: "+" };
// Tag for left associativity (right assoc is implied by undefined).
-ASSOC_LEFT = true;
+google.ASSOC_LEFT = true;
// The productions of the grammar. Columns of the table:
//
@@ -1855,7 +1855,7 @@
// instead. TODO: It shouldn't be necessary to explicitly assign
// precedences to rules.
-xpathGrammarRules =
+google.xpathGrammarRules =
[
[ XPathLocationPath, [ XPathRelativeLocationPath ], 18,
passExpr ],
@@ -2003,9 +2003,9 @@
// structures and will be called right here. It merely takes the
// counter variables out of the global scope.
-xpathRules = [];
+google.xpathRules = [];
-xpathParseInit = function() {
+google.xpathParseInit = function() {
if (xpathRules.length) {
return;
}
@@ -2087,14 +2087,14 @@
// Local utility functions that are used by the lexer or parser.
-xpathCollectDescendants = function(nodelist, node) {
+google.xpathCollectDescendants = function(nodelist, node) {
for (var n = node.firstChild; n; n = n.nextSibling) {
nodelist.push(n);
arguments.callee(nodelist, n);
}
}
-xpathCollectDescendantsReverse = function(nodelist, node) {
+google.xpathCollectDescendantsReverse = function(nodelist, node) {
for (var n = node.lastChild; n; n = n.previousSibling) {
nodelist.push(n);
arguments.callee(nodelist, n);
@@ -2104,7 +2104,7 @@
// The entry point for the library: match an expression against a DOM
// node. Returns an XPath value.
-xpathDomEval = function(expr, node) {
+google.xpathDomEval = function(expr, node) {
var expr1 = xpathParse(expr);
var ret = expr1.evaluate(new ExprContext(node));
return ret;
@@ -2112,7 +2112,7 @@
// Utility function to sort a list of nodes. Used by xsltSort() and
// nxslSelect().
-xpathSort = function(input, sort) {
+google.xpathSort = function(input, sort) {
if (sort.length == 0) {
return;
}
@@ -2164,7 +2164,7 @@
// the case that numbers should be sorted as strings, which is very
// uncommon.
-xpathSortByKey = function(v1, v2) {
+google.xpathSortByKey = function(v1, v2) {
// NOTE: Sort key vectors of different length never occur in
// xsltSort.
@@ -2179,3 +2179,7 @@
return 0;
}
+
+}
+
+
Modified: incubator/xap/trunk/src/google/xpathdebug.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/xpathdebug.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/google/xpathdebug.js (original)
+++ incubator/xap/trunk/src/google/xpathdebug.js Fri Jun 30 13:59:42 2006
@@ -215,7 +215,7 @@
return indent + '[variable] ' + this.toString() + '\n';
}
-XNode.prototype.toString = function() {
+google.XNode.prototype.toString = function() {
return this.nodeName;
}
Modified: incubator/xap/trunk/src/xap/Xap.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/Xap.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/Xap.js (original)
+++ incubator/xap/trunk/src/xap/Xap.js Fri Jun 30 13:59:42 2006
@@ -21,6 +21,7 @@
//make xap load from the xap directory
dojo.hostenv.setModulePrefix("xap", "../xap");
+dojo.hostenv.setModulePrefix("google", "../google");
Xap.kwCompoundRequire = function(){
@@ -53,12 +54,6 @@
}
Xap.loadXap = function( sourceRootDir ) {
-
- dojo.hostenv.loadUri(sourceRootDir + "/src/google/misc.js");
- dojo.hostenv.loadUri(sourceRootDir + "/src/google/xpath.js");
- dojo.hostenv.loadUri(sourceRootDir + "/src/google/dom.js");
-
-
//xap.util
dojo.hostenv.loadUri( sourceRootDir + "/src/xap/util/LogFactory.js");
dojo.hostenv.loadUri( sourceRootDir + "/src/xap/util/XmlUtils.js" );
Modified: incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js Fri Jun 30 13:59:42 2006
@@ -17,6 +17,7 @@
//TODO we need to handle qualifying URLs properly based on the request page again
+Xap.require("google.*");
/**
* @fileoverview The base class for all element to peer object
* bridges.
@@ -210,7 +211,7 @@
//way to do this
for ( var i = 0; i < children.length; i++ ) {
var child = children[i];
- if ( child.nodeType==DOM_ELEMENT_NODE ) {
+ if ( child.nodeType==google.DOM_ELEMENT_NODE ) {
contentHandler.parseChild( child );
//-1 index means an append, even though we already have
@@ -220,7 +221,7 @@
this.beforeChildAdded( event );
this.onChildAdded( event );
}
- if ( child.nodeType==DOM_TEXT_NODE ) {
+ if ( child.nodeType==google.DOM_TEXT_NODE ) {
//TODO this needs some work in that they are supposed to be able
//to CHANGE the text in the beforeChildAdded and that is supposed to
//be what we actually add. This can happen with databinding syntax
Modified: incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js Fri Jun 30 13:59:42 2006
@@ -15,6 +15,8 @@
*
*/
+Xap.require("google.*");
+
/**
* @fileoverview PluginDocumentHandler manages creating bridge classes
* for tags on a single document.
@@ -119,7 +121,7 @@
//recursively de-register all children
for ( var i = 0; i < el.childNodes.length; i++ ) {
var child = el.childNodes[i];
- if ( child.nodeType == DOM_ELEMENT_NODE ) {
+ if ( child.nodeType == google.DOM_ELEMENT_NODE ) {
this.deregister( child );
}
}
Modified: incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/PluginRegistryImpl.js Fri Jun 30 13:59:42 2006
@@ -15,6 +15,7 @@
*
*/
+Xap.require("google.xpath");
/**
* @fileoverview Work in progress.
*
@@ -85,19 +86,19 @@
//TODO this returs what an array of nodes?
var tagMappingSections =
- xpathDomEval(PluginRegistryImpl.TAG_MAPPINGS_PATH , pluginDocument);
+ google.xpathDomEval(PluginRegistryImpl.TAG_MAPPINGS_PATH , pluginDocument);
PluginRegistryImpl.s_log.debug(tagMappingSections.value.length + " mapped tags");
this._parseTagMappingElements(tagMappingSections.value,true);
PluginRegistryImpl.s_log.debug("Parse unmapped tags");
tagMappingSections =
- xpathDomEval(PluginRegistryImpl.UNMAPPED_TAGS_PATH , pluginDocument);
+ google.xpathDomEval(PluginRegistryImpl.UNMAPPED_TAGS_PATH , pluginDocument);
PluginRegistryImpl.s_log.debug(tagMappingSections.value.length + " unmapped tags");
this._parseTagMappingElements(tagMappingSections.value,false);
//TODO this returns an array but we want a string, get the first element node value?
var lifecycleClassName =
- xpathDomEval(PluginRegistryImpl.PLUGIN_LIFECYCLE_CLASS_PATH , pluginDocument).value[0];
+ google.xpathDomEval(PluginRegistryImpl.PLUGIN_LIFECYCLE_CLASS_PATH , pluginDocument).value[0];
PluginRegistryImpl.s_log.debug("lifecycle class = " + lifecycleClassName);
Modified: incubator/xap/trunk/src/xap/xml/dom/Document.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/dom/Document.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/Document.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/Document.js Fri Jun 30 13:59:42 2006
@@ -15,6 +15,8 @@
*
*/
+Xap.require("google.dom");
+
/**
* @fileoverview The Document object represents an entire XML document.
* Conceptually, it is the root of the document tree, and provides the
@@ -28,7 +30,7 @@
/**
* Creates a Document instance.
- * @extends XDocument
+ * @extends google.XDocument
* @class The Document object represents an entire XML document. Conceptually, it
* is the root of the document tree, and provides the primary access to the
* document's data.
@@ -52,7 +54,7 @@
* @param rootElement The root Element for the newly created document.
*/
Document = function( rootElement ) {
- XDocument.call(this);
+ google.XDocument.call(this);
this._rootElement = rootElement;
this._documentEncoding = null;
@@ -66,7 +68,7 @@
this._notificationListener = null;
this._uidProvider = new UidProvider();
}
-Document.prototype = new XDocument();
+Document.prototype = new google.XDocument();
/**
* @private
@@ -475,7 +477,7 @@
e._notifyListenersOnAddedToDocument( this );
for( var i=0; i < e.getChildCount(); i++ ) {
var o = e.getChildAt( i );
- if (o.nodeType==DOM_ELEMENT_NODE){
+ if (o.nodeType==google.DOM_ELEMENT_NODE){
this._addDocumentFragmentToIdMapAndCheckForPrefixCollisions( o );
}
}
@@ -489,7 +491,7 @@
e._notifyListenersOnRemovedFromDocument( this );
for( var i=0; i < e.getChildCount(); i++ ) {
var o = e.getChildAt( i );
- if (o.nodeType==DOM_ELEMENT_NODE){
+ if (o.nodeType==google.DOM_ELEMENT_NODE){
this._removeDocumentFragmentFromIdMap( o );
}
}
Modified: incubator/xap/trunk/src/xap/xml/dom/XapElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/dom/XapElement.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/XapElement.js Fri Jun 30 13:59:42 2006
@@ -15,6 +15,7 @@
*
*/
+Xap.require("google.dom");
/**
* @fileoverview An DOM element node implementation that supports
* notification of changes.
@@ -44,7 +45,7 @@
*/
XapElement = function(elementName, ownerDoc, parentEl, id, uidProvider ){
- XNode.call(this, DOM_ELEMENT_NODE, elementName, null, ownerDoc)
+ google.XNode.call(this, google.DOM_ELEMENT_NODE, elementName, null, ownerDoc)
this._namespaceUri = null;
this._prefix = null;
@@ -63,7 +64,7 @@
this.setAttribute( "id", uidProvider.nextId() );
}
}
-XapElement.prototype = new XNode();
+XapElement.prototype = new google.XNode();
// Venkman gets class string from here:
XapElement.prototype.constructor = XapElement ;
@@ -213,7 +214,7 @@
event.setNewValue( value );
}
- XNode.prototype.setAttribute.call(this, name, value);
+ google.XNode.prototype.setAttribute.call(this, name, value);
if ( attributeChangeListenersExist ) {
this._notifyListenersOnAttributeChange( doc, event );
@@ -233,7 +234,7 @@
var event = new AttributeChangeEvent(this, name, null);
this._notifyListenersBeforeAttributeRemoval( doc, event );
// Actually perform the removal:
- XNode.prototype.removeAttribute.call(this, name);
+ google.XNode.prototype.removeAttribute.call(this, name);
this._notifyListenersOnAttributeRemoval( doc, event );
// We never allow elements not to have IDs - if the id attribute tries
@@ -254,8 +255,8 @@
/**
* Inserts the new child newNode before existing child oldNode.
- * @param {XNode} newNode The new child to insert.
- * @param {XNode} oldNode The existing child to insert before.
+ * @param {google.XNode} newNode The new child to insert.
+ * @param {google.XNode} oldNode The existing child to insert before.
*/
XapElement.prototype.insertBefore = function(newNode, oldNode) {
return this._insertBefore( newNode, oldNode );
@@ -263,7 +264,7 @@
/**
* Appends the given child to this element.
*
- * @param {XNode} child The child text or element node to append.
+ * @param {google.XNode} child The child text or element node to append.
*/
XapElement.prototype.appendChild = function(child){
return this._insertBefore( child );
@@ -273,7 +274,7 @@
/**
* Removes the given child from this element.
*
- * @param {XNode} child The child text or element node to remove.
+ * @param {google.XNode} child The child text or element node to remove.
*/
XapElement.prototype.removeChild = function(child){
if ( this.childNodes == null ) {
@@ -307,11 +308,11 @@
}
//make the actual change
- XNode.prototype.removeChild.call(this,child);
+ google.XNode.prototype.removeChild.call(this,child);
//if we are removing an element node we have to remove it from
//our ID map and clean up owner doc stuff
- if (child.nodeType==DOM_ELEMENT_NODE){
+ if (child.nodeType==google.DOM_ELEMENT_NODE){
if ( doc != null ) {
doc._removeDocumentFragmentFromIdMap( child );
}
@@ -399,7 +400,7 @@
*/
XapElement.prototype.getParent = function() {
if (!this.parentNode) return null;
- if (this.parentNode.nodeType!=DOM_ELEMENT_NODE) return null;
+ if (this.parentNode.nodeType!=google.DOM_ELEMENT_NODE) return null;
return this.parentNode;
}
@@ -661,7 +662,7 @@
}
}
- var isElement = (newNode.nodeType == DOM_ELEMENT_NODE);
+ var isElement = (newNode.nodeType == google.DOM_ELEMENT_NODE);
if (isElement) {
// We need to ensure that if there is an owner document already
@@ -690,12 +691,12 @@
//if there was an old node we are doing an insert before
if (oldNode){
- XNode.prototype.insertBefore.call(this,newNode, oldNode);
+ google.XNode.prototype.insertBefore.call(this,newNode, oldNode);
}
//otherwise we are doing an append
else{
- XNode.prototype.appendChild.call(this,newNode);
+ google.XNode.prototype.appendChild.call(this,newNode);
}
if ( structureChangeListenersExist ) {
@@ -845,7 +846,7 @@
XapElement.prototype._toStringHelper = function( node, sbuf, indent, prettyPrint,
withInternalIds,
attributeEncodingChoice ) {
- if( node.nodeType == DOM_TEXT_NODE ) {
+ if( node.nodeType == google.DOM_TEXT_NODE ) {
// if its a string, simply print it XML-encoded
sbuf += XmlUtils.encode( node.nodeValue );
} else {
@@ -858,7 +859,7 @@
} else {
//var child = node.getParent().getChildAt(index-1);
if ( index == 0 ||
- ( node.getParent().getChildAt(index-1).nodeType==DOM_ELEMENT_NODE)) {
+ ( node.getParent().getChildAt(index-1).nodeType==google.DOM_ELEMENT_NODE)) {
sbuf += '\n';
XapElement._writeIndent( sbuf, indent );
}
@@ -947,7 +948,7 @@
var elementHasTextNode = false;
for ( var i = 0; i < node.getChildCount(); i++ ) {
var child = node.getChildAt(i);
- if( child.nodeType == DOM_TEXT_NODE ) {
+ if( child.nodeType == google.DOM_TEXT_NODE ) {
elementHasTextNode = true;
}
sbuf = this._toStringHelper(child,
@@ -1561,14 +1562,14 @@
for ( var i = 0; i < this.getChildCount(); i++ ) {
var o = this.getChildAt(i);
- if (o.nodeType==DOM_ELEMENT_NODE){
+ if (o.nodeType==google.DOM_ELEMENT_NODE){
var childCopy = o._cloneHelper( deep, withIds, parser );
e.appendChild( childCopy );
}
- else if (o.nodeType==DOM_TEXT_NODE){
+ else if (o.nodeType==google.DOM_TEXT_NODE){
//TODO we should really use document.createTextNode here
//but do we always have a document to reference?
- var childCopy = XNode.create(DOM_TEXT_NODE,null,o.nodeValue,null);
+ var childCopy = google.XNode.create(google.DOM_TEXT_NODE,null,o.nodeValue,null);
e.appendChild( childCopy );
}
}
Modified: incubator/xap/trunk/src/xap/xml/dom/events/StructureChangeEvent.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/dom/events/StructureChangeEvent.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/events/StructureChangeEvent.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/events/StructureChangeEvent.js Fri Jun 30 13:59:42 2006
@@ -15,6 +15,7 @@
*
*/
+Xap.require("google.dom");
/* @fileoverview StructureChangeEvent objects are passed to the methods of the
* {@link StructureChangeListener} class when changes in Document
* structure occur.
@@ -41,7 +42,7 @@
this._index = index;
if( parent == null ) {
this._eventType = StructureChangeEvent.ROOT_NODE;
- } else if ( changeNode.nodeType == DOM_ELEMENT_NODE ) {
+ } else if ( changeNode.nodeType == google.DOM_ELEMENT_NODE ) {
this._eventType = StructureChangeEvent.ELEMENT_NODE;
} else {
this._eventType = StructureChangeEvent.TEXT_NODE;
@@ -128,14 +129,14 @@
//if the root node is changing we expect the change to be an element,
//not a text node...do we have to do this?
if ( this._eventType == StructureChangeEvent.ROOT_NODE ) {
- if ( newChange.nodeType != DOM_ELEMENT_NODE ) {
+ if ( newChange.nodeType != google.DOM_ELEMENT_NODE ) {
//TODO i18n
throw new IllegalArgumentException
( "The root element of Documents must be of type Element" );
}
}
- else if ( newChange.nodeType == DOM_ELEMENT_NODE ) {
+ else if ( newChange.nodeType == google.DOM_ELEMENT_NODE ) {
this._eventType = StructureChangeEvent.ELEMENT_NODE;
}
else {
Modified: incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js?rev=418375&r1=418374&r2=418375&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js Fri Jun 30 13:59:42 2006
@@ -14,6 +14,9 @@
* limitations under the License.
*
*/
+
+Xap.require("google.dom");
+
/**
* @fileoverview An object embodying a particular operation (e.g., <code>append</code>) to be performed
* on a targetted part of the UI document (as specifically using either
@@ -175,7 +178,7 @@
}
} else {
var currentContext = new ExprContext(uiDocumentNode) ;
- var parsedXPathExpr = xpathParse(localSelectString) ;
+ var parsedXPathExpr = google.xpathParse(localSelectString) ;
var targetNodes = parsedXPathExpr.evaluate( currentContext );
var targetNodesArray = targetNodes.nodeSetValue();
@@ -212,7 +215,7 @@
*/
var currentNode = targetNodes[i];
- if (currentNode.nodeType == DOM_DOCUMENT_NODE ){
+ if (currentNode.nodeType == google.DOM_DOCUMENT_NODE ){
if (elemsToAppend.length != 1)
{
throw new XmodifyException(XmodifyException.SET_ROOT_ELEMENT_EXPECTS_ONE_ARG);
@@ -224,7 +227,7 @@
);
currentNode.setRootElement(elemsToAppend[0]);
- } else if (currentNode.nodeType == DOM_ELEMENT_NODE ){
+ } else if (currentNode.nodeType == google.DOM_ELEMENT_NODE ){
for (var j = 0; j < elemsToAppend.length; j++){
try {
currentNode.appendChild(elemsToAppend[j].deepClone(false));
@@ -276,7 +279,7 @@
for (var i = 0; i < targetNodes.length; i ++){
var currentNode = targetNodes[i];
- if (currentNode.nodeType == DOM_ELEMENT_NODE ){
+ if (currentNode.nodeType == google.DOM_ELEMENT_NODE ){
for (var j = 0 ; j < attrsToSet.length; j++){
try {
var attrToSet = attrsToSet[j];
@@ -348,7 +351,7 @@
I can't use getParent either.. although in the Java code you do both.
I assume it's a string. Can I simply use setFirst.. instead?
*/
- if (elem.nodeType == DOM_ELEMENT_NODE)
+ if (elem.nodeType == google.DOM_ELEMENT_NODE)
{
var parent = elem.getParent();
@@ -361,7 +364,7 @@
uiDocumentNode.setRootElement(null);
}
}
- else if (elem.nodeType == DOM_TEXT_NODE)
+ else if (elem.nodeType == google.DOM_TEXT_NODE)
{
Xmodify.s_log.debug ("Removing text node: "+elem.nodeValue());
var parent = elem.getParent();
@@ -456,7 +459,7 @@
for (var i = 0; i < targetNodes.length ; i ++){
var currentNode = targetNodes[i];
- if (currentNode.nodeType == DOM_ELEMENT_NODE ){
+ if (currentNode.nodeType == google.DOM_ELEMENT_NODE ){
for (var j = 0 ; j < attrsToRemove.length ; j++) {
try {
@@ -510,7 +513,7 @@
// ValueOfDirective)*
var arg = arrArguments[ii] ;
// Just try it for XNode and descendants so far:
- if (arg instanceof XNode){
+ if (arg instanceof google.XNode){
parent.insertChildAt(index, arg);
} else {
throw new XmodifyException("Can't insert the desired element, can only insert XNode (or descendant) instances so far.") ;
@@ -584,7 +587,7 @@
parent = currentNode.parentNode ;
- if (currentNode.nodeType == DOM_ELEMENT_NODE) {
+ if (currentNode.nodeType == google.DOM_ELEMENT_NODE) {
if ( parent != null ) {
// No longer necessary or appropriate,
// given that the concept of inserting at an
@@ -599,9 +602,9 @@
)
};
- } else if (currentNode.nodeType == DOM_TEXT_NODE) {
+ } else if (currentNode.nodeType == google.DOM_TEXT_NODE) {
index = parent.getChildren().indexOf(currentNode) + 1;
- } else if (currentNode.nodeType == DOM_ATTRIBUTE_NODE) {
+ } else if (currentNode.nodeType == google.DOM_ATTRIBUTE_NODE) {
//TODO we might want to make it work in the future.
// to make it work for attributes we'll need additional
// API on the Element: setAttributeAt
@@ -647,7 +650,7 @@
parent = currentNode.parentNode ;
- if (currentNode.nodeType == DOM_ELEMENT_NODE) {
+ if (currentNode.nodeType == google.DOM_ELEMENT_NODE) {
if ( parent != null ) {
// No longer necessary or appropriate,
// given that the concept of inserting at an
@@ -662,9 +665,9 @@
)
};
- } else if (currentNode.nodeType == DOM_TEXT_NODE) {
+ } else if (currentNode.nodeType == google.DOM_TEXT_NODE) {
index = parent.getChildren().indexOf(currentNode) + 1;
- } else if (currentNode.nodeType == DOM_ATTRIBUTE_NODE) {
+ } else if (currentNode.nodeType == google.DOM_ATTRIBUTE_NODE) {
//TODO we might want to make it work in the future.
// to make it work for attributes we'll need additional
// API on the Element: setAttributeAt
@@ -709,7 +712,7 @@
// ValueOfDirective)*
var newChild = arrArguments[ii] ;
// Just try it for XNode and descendants so far:
- if (oldChild instanceof XNode){
+ if (oldChild instanceof google.XNode){
var nextOldChild = oldChild.nextSibling ;
if (true||nextOldChild != null){
parent.insertBefore(
@@ -741,7 +744,7 @@
// ValueOfDirective)*
var newChild = arrArguments[ii] ;
// Just try it for XNode and descendants so far:
- if (oldChild instanceof XNode){
+ if (oldChild instanceof google.XNode){
parent.insertBefore(
newChild.deepClone(false),
oldChild
@@ -781,7 +784,7 @@
// ValueOfDirective)*
var oldChild = targetNodes[ii] ;
// Just try it for XNode and descendants so far:
- if (oldChild instanceof XNode){
+ if (oldChild instanceof google.XNode){
Xmodify.s_log.debug("Pre replacing <" + oldChild.nodeName+"/>:\n" + oldChild.parentNode.toXml(true));
this._replaceWithCommandArguments(oldChild) ;
Xmodify.s_log.debug("Post replacing: <" + oldChild.nodeName+"/>:\n" + oldChild.parentNode.toXml(true) );
@@ -816,7 +819,7 @@
// ValueOfDirective)
newChild = arrArguments[ii] ;
// Just try it for XNode and descendants so far:
- if (oldChild instanceof XNode){
+ if (oldChild instanceof google.XNode){
Xmodify.s_log.debug(
"Pre insertion of " + newChild.toXml(true)+"\nbefore\n"
+ oldChild.toXml(true)
@@ -878,7 +881,7 @@
for (var ll=0; ll<this._commandTargets.length; ++ll) {
var toClone = this._commandTargets[ll] ;
- if (toClone.nodeType == DOM_ELEMENT_NODE) {
+ if (toClone.nodeType == google.DOM_ELEMENT_NODE) {
var cloned = toClone.deepClone(false) ;
this._clones[ll] = clone ;
} else {