incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r419707 - in /incubator/xap/trunk: WebContent/examples/google/ src/xap/ src/xap/macro/ src/xap/session/ src/xap/taghandling/ src/xap/util/ src/xap/xml/dom/ src/xap/xml/xmodify/ testsrc/ testsrc/xap/util/ testsrc/xap/util/Vector/ testsrc/xap...
Date Thu, 06 Jul 2006 21:31:04 GMT
Author: jmargaris
Date: Thu Jul  6 14:31:03 2006
New Revision: 419707

URL: http://svn.apache.org/viewvc?rev=419707&view=rev
Log:
Removed vector class, simplified element and document
and removed some methods that were not org.w3c

Added:
    incubator/xap/trunk/src/xap/util/ArrayHelper.js   (with props)
Removed:
    incubator/xap/trunk/src/xap/util/Vector.js
    incubator/xap/trunk/testsrc/xap/util/Vector/
    incubator/xap/trunk/testsrc/xap/util/_TestVector.html
Modified:
    incubator/xap/trunk/WebContent/examples/google/EventMco.js
    incubator/xap/trunk/WebContent/examples/google/index.html
    incubator/xap/trunk/src/xap/Xap.js
    incubator/xap/trunk/src/xap/macro/MacroNamespaceHandler.js
    incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js
    incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js
    incubator/xap/trunk/src/xap/util/XapException.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/xmodify/CommandDirective.js
    incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js
    incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js
    incubator/xap/trunk/testsrc/XapUnitTestSuite.html
    incubator/xap/trunk/testsrc/xap/xml/_TestDocument.js
    incubator/xap/trunk/testsrc/xap/xml/_TestElement.js
    incubator/xap/trunk/testsrc/xap/xml/_TestParser.html

Modified: incubator/xap/trunk/WebContent/examples/google/EventMco.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/google/EventMco.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/google/EventMco.js (original)
+++ incubator/xap/trunk/WebContent/examples/google/EventMco.js Thu Jul  6 14:31:03 2006
@@ -94,8 +94,8 @@
 	var googleMapMarkers = uiDoc.getElementById("googleMapMarkers");
 	
 	//remove all the markers from the 
-	for (index = 0; index < googleMapMarkers.getChildCount();){
-	    var element = googleMapMarkers.getChildAt(index);
+	for (index = 0; index < googleMapMarkers.childNodes.length;){
+	    var element = googleMapMarkers.childNodes[index];
 	    googleMapMarkers.removeChild(element);
 	}	   
 

Modified: incubator/xap/trunk/WebContent/examples/google/index.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/google/index.html?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/google/index.html (original)
+++ incubator/xap/trunk/WebContent/examples/google/index.html Thu Jul  6 14:31:03 2006
@@ -25,7 +25,7 @@
     	 
     	 Key for venus - ABQIAAAAcOjK825sBWPNSrYVCbWotxRyfcNEDSWJvnTszUbpwkw2ji4BTRRCwc-w5xoc0Q5t7xolzbKKgcfK4g
      -->
-    <script language="JavaScript" type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAcOjK825sBWPNSrYVCbWotxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxRa-rKcUwREi2Buc-2TMkIfDCCI_g"></script>
+    <script language="JavaScript" type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAyG2ywpWi86lgJbv0Vh_L5RQz5JJ2zPi3YI9JDWBFF6NSsxhe4BQ4JIFHgcLVTdtjpPRBWzBkudRryQ"></script>
 
 	 <script language="JavaScript" type="text/javascript" src="../../src/dojo/dojo.js"></script>
     <script language="JavaScript" type="text/javascript" src="../../src/xap/util/Utils.js"></script>

Modified: incubator/xap/trunk/src/xap/Xap.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/Xap.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/Xap.js (original)
+++ incubator/xap/trunk/src/xap/Xap.js Thu Jul  6 14:31:03 2006
@@ -76,7 +76,6 @@
 	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/XmlUtils.js" );
 	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/HttpUtils.js" );
 	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/UidProvider.js" );
-	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/Vector.js" );
 	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/Hashtable.js" );
 	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/ResourceDictionary.js" );
 	dojo.hostenv.loadUri(  sourceRootDir + "/src/xap/util/XapException.js" );

Modified: incubator/xap/trunk/src/xap/macro/MacroNamespaceHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/macro/MacroNamespaceHandler.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/macro/MacroNamespaceHandler.js (original)
+++ incubator/xap/trunk/src/xap/macro/MacroNamespaceHandler.js Thu Jul  6 14:31:03 2006
@@ -69,7 +69,7 @@
 	 
 	//TODO we really need to clarify whether or not XAP is a generic wrapping
 	//tag or something with more meaning
-	var macro = new Macro( "<xap>" + element.getChildAt(0).toXmlWithoutAutoAssignedIds() + "</xap>", this.getSession() );
+	var macro = new Macro( "<xap>" + element.childNodes[0].toXmlWithoutAutoAssignedIds() + "</xap>", this.getSession() );
 	 
 	//TODO if we are replacing and existing one should probably
 	//output that to info at least.

Modified: incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js (original)
+++ incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js Thu Jul  6 14:31:03 2006
@@ -487,7 +487,7 @@
 		return o[methodName].apply(o,args);
 	}
 	catch( exception ){
-		throw new BaseException("Error calling method :" + methodName);
+		throw new BaseException("Error calling method :" + methodName, exception);
 	}
 
 	return null;

Modified: incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/PluginDocumentHandler.js Thu Jul  6 14:31:03 2006
@@ -49,7 +49,9 @@
 	this._peersToBridges = new Hashtable();
 	this._clientSession = clientSession;
 	this._documentName = documentName;
-	doc._addSystemStructureChangeListener( this );
+	
+	//we had better be the first listener on the document!
+	doc.addStructureChangeListener( this );
 }
 
 /** @private */

Added: incubator/xap/trunk/src/xap/util/ArrayHelper.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/ArrayHelper.js?rev=419707&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/util/ArrayHelper.js (added)
+++ incubator/xap/trunk/src/xap/util/ArrayHelper.js Thu Jul  6 14:31:03 2006
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ *
+ */
+ 
+Xap.provide("xap.util.ArrayHelper");
+//TODO like many classes exception handling here needs to be
+//more thought out.
+
+/**
+ * @fileoverview A class that helps add some functionality to arrays.
+ *
+ * @author jmargaris
+ */
+ 
+/**
+ * There is no need to ever construct a ArrayHelper object
+ * at this time, just use the static methods.
+ * 
+ * @class ArrayHelper provides methods to implement some common
+ * functions missing on arrays. (At least in some JS versions)
+ * This is intended to be simpler and more straightforward
+ * than either wrapping an array in a new data structure
+ * or changing the array prototype.
+ * 
+ * @constructor
+ */
+xap.util.ArrayHelper = function(){}
+
+/**
+ * Removes the first occurence of the given element
+ * from the given array.
+ * 
+ * @param {Array} array The array to remove the element from.
+ * @param element The element to remove from the array.
+ * @return {Array} The array with the element removed.
+ */ 
+xap.util.ArrayHelper.removeElement = function( array, element){
+	if (!array){
+		return null;
+	}	
+	var i = xap.util.ArrayHelper.indexOf(array, element);
+	if (i<0){
+		return null;
+	}
+	return array.splice(i,1);
+}
+
+/**
+ * Returns the first index of the given element in the 
+ * given array.
+ * 
+ * @param {Array} array The array to look in.
+ * @param element The element to look for.
+ * @return {Integer} The index of the element, or -1 if not found.
+ */ 
+xap.util.ArrayHelper.indexOf = function( array, element){
+	if (!array){
+		return null;
+	}	
+	for (var i =0; i<array.length; i++){
+		if (array[i]==element){
+			return i;
+		}
+	}
+	return -1;
+}
\ No newline at end of file

Propchange: incubator/xap/trunk/src/xap/util/ArrayHelper.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/xap/trunk/src/xap/util/XapException.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/util/XapException.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/util/XapException.js (original)
+++ incubator/xap/trunk/src/xap/util/XapException.js Thu Jul  6 14:31:03 2006
@@ -103,8 +103,11 @@
 XapException.exceptionToString = function(exception){
 	var s = new String();
 	
+	if (!exception){
+		return s;
+	}
 	
-	if (exception.name){ //should exist for browser exceptions
+	if (exception.name && exception.message){ //should exist for browser exceptions
 		s+= "Exception: " + exception.name + " - " + exception.message + "\n";
 	}
 	
@@ -113,15 +116,15 @@
 	}
 	
 	if (exception.getLocation && exception.getLocation()){
-		s+="Occurred at:" + exception.getLocation() + "\n";
+		s+="Occured at:" + exception.getLocation() + "\n";
 	}
 	
-	if (exception.getCause){
+	if (exception.getCause && exception.getCause()){
 		s+="Caused by:\n" + XapException.exceptionToString(exception.getCause());
 	}
 	
 	//next-to-last resort just use toString
-	if (s.length==0 && s.toString){
+	if (s.length==0 && exception.toString){
 		s = exception.toString();
 	}
 	// last resort: let JS sort it out:

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=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/Document.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/Document.js Thu Jul  6 14:31:03 2006
@@ -16,6 +16,7 @@
  */
  
 Xap.require("google.dom");
+Xap.require("xap.util.ArrayHelper");
  
 /**
  * @fileoverview The Document object represents an entire XML document. 
@@ -58,67 +59,16 @@
     this._rootElement = rootElement;
     this._documentEncoding = null;
     
-    this._systemStructureChangeListeners = null; 
-    this._systemAttributeChangeListeners = null; 
-    this._structureChangeListeners = null; 
-    this._attributeChangeListeners = null; 
+    this._structureChangeListeners = new Array(); 
+    this._attributeChangeListeners = new Array(); 
     
     this._idToElementMap = new Object();
     this._prefixToNamespaceMap = new Object();
-    this._notificationListener = null;
     this._uidProvider = new UidProvider();
 }
-Document.prototype = new google.XDocument();
-
-/**
- * @private
- */
-Document.prototype._rootElement = null;
-
-/**
- * @private
- */
-Document.prototype._documentEncoding = null;
-
-/**
- * @private
- */
-Document.prototype._systemStructureChangeListeners = null;
-
-/**
- * @private
- */
-Document.prototype._systemAttributeChangeListeners = null;
-
-/**
- * @private
- */
-Document.prototype._structureChangeListeners = null;
-
-/**
- * @private
- */
-Document.prototype._attributeChangeListeners = null;
-
-/**
- * @private
- */
-Document.prototype._idToElementMap = null;
-
-/**
- * @private
- */
-Document.prototype._prefixToNamespaceMap = null;
 
-/**
- * @private
- */
-Document.prototype._notificationListener = null;
+Document.prototype = new google.XDocument();
 
-/**
- * @private
- */
-Document.prototype._uidProvider = null;
 
 //-----------------------------------------------------------------------
 // Constants.
@@ -194,7 +144,7 @@
  * @param listener The AttributeChangeListener to add
  */
 Document.prototype.addAttributeChangeListener = function( listener ) {
-	this._getAttributeChangeListeners().addElement( listener );
+	this._attributeChangeListeners.push( listener );
 }
 
 /**
@@ -202,7 +152,7 @@
  * @param The listener to remove
  */
 Document.prototype.removeAttributeChangeListener = function( listener ) {
-	return this._getAttributeChangeListeners().removeElement( listener );
+	return xap.util.ArrayHelper.removeElement(this._attributeChangeListeners, listener);
 }
 
 /**
@@ -210,7 +160,7 @@
  * @param listener The listener to add
  */
 Document.prototype.addStructureChangeListener = function( listener ) {
-	this._getStructureChangeListeners().addElement( listener );
+	this._structureChangeListeners.push( listener );
 }
 
 /**
@@ -218,7 +168,7 @@
  * @param listener The listener to remove.
  */
 Document.prototype.removeStructureChangeListener = function( listener ) {
-	return this._getStructureChangeListeners().removeElement( listener );
+	return xap.util.ArrayHelper.removeElement(this._structureChangeListeners, listener);
 }
 
 /**
@@ -244,82 +194,56 @@
 	//TODO waht about appendChild and remove child()? we need to
 	//override those too?
 	
-    if ( root == null && this._rootElement == null ) {
-        // If the old root was null and the new root is null then we're
-        // already in the desired state, don't fire any events, just
-        // return.
-        return;
-    } 
+	if ( root == null && this._rootElement == null ) {
+		// If the old root was null and the new root is null then we're
+		// already in the desired state, don't fire any events, just
+		// return.
+		return;
+	} 
 
 	// remove the current root element from this Document.
-    this._removeExistingRoot();
+	this._removeExistingRoot();
 	
 	if ( root != null ) {
-        var event = new StructureChangeEvent( null, root );
-        // Just as in ElementImpl's notification of listeners at 
-        // the document level, use the notification listener around
-        // the user listeners only.
-        
-        this._notifyListenersOfStructureChange
-            ( this._getSystemStructureChangeListeners(), event, Document.BEFORE_ADD );
-        if ( this._notificationListener != null ) {
-            this._notificationListener.beforeNotification();
-        }
+		var event = new StructureChangeEvent( null, root );
         
-        try {
-            this._notifyListenersOfStructureChange
-                ( this._getStructureChangeListeners(), event, Document.BEFORE_ADD );
-        } finally {
-            if ( this._notificationListener != null ) {
-                this._notificationListener.afterNotification();
-            }
-        }
+   
+		this._notifyListenersOfStructureChange
+			( this._structureChangeListeners, event, Document.BEFORE_ADD );
+      
         
-        // Take the element from the event because they have the
-        // opportunity to change the element in the event.  It is safe to
-        // cast here because the event itself guarantees that root element
-        // events can't be changed to text nodes.
+		// Take the element from the event because they have the
+		// opportunity to change the element in the event.  It is safe to
+		// cast here because the event itself guarantees that root element
+		// events can't be changed to text nodes.
 	
 		this._rootElement = event.getChange();
         
-        if ( this._rootElement.getParent() != null ) {
-            // remove the to-be root from its current parent and owner
-            // document.
-            this._rootElement.getParent().removeChild( this._rootElement );
-        } 
+		if ( this._rootElement.getParent() != null ) {
+			// remove the to-be root from its current parent and owner
+			// document.
+			this._rootElement.getParent().removeChild( this._rootElement );
+		} 
         
-        else if ( this._rootElement.getOwnerDocument() != null &&
-                    this._rootElement.getOwnerDocument()
-                    .getRootElement() == this._rootElement ) {
-            // Another possibility is that the to-be root is the 
-            // root element of another document.  Make sure that
-            // the other document is correctly maintained.
-            this._rootElement.getOwnerDocument().setRootElement( null );
-        }
-        this._rootElement._setOwnerDocument( this );
+		else if ( this._rootElement.getOwnerDocument() != null &&
+			this._rootElement.getOwnerDocument().getRootElement() == this._rootElement ) {
+			// Another possibility is that the to-be root is the 
+			// root element of another document.  Make sure that
+     		// the other document is correctly maintained.
+  			this._rootElement.getOwnerDocument().setRootElement( null );
+		}
+		this._rootElement._setOwnerDocument( this );
         
-        //this should handle the xdocument hookup
-        this.appendChild(this._rootElement);
+		//this should handle the xdocument hookup
+		this.appendChild(this._rootElement);
 		
 		this._addDocumentFragmentToIdMapAndCheckForPrefixCollisions( this._rootElement );
         
-        // Just as in ElementImpl's notification of listeners at 
-        // the document level, use the notification listener around
-        // the user listeners only.
-        this._notifyListenersOfStructureChange( 
-        	this._getSystemStructureChangeListeners(), event, Document.ON_ADD );
-        if ( this._notificationListener != null ) {
-            this._notificationListener.beforeNotification();
-        }
-        try {
-            this._notifyListenersOfStructureChange( 
-            	this._getStructureChangeListeners(), event, Document.ON_ADD );
-        } finally {
-            if ( this._notificationListener != null ) {
-                this._notificationListener.afterNotification();
-            }
-        }
-    } else {
+		this._notifyListenersOfStructureChange( 
+			this._structureChangeListeners, event, Document.ON_ADD );
+        
+        
+	} else {
 		this._rootElement = null;
 	}
 }
@@ -362,85 +286,10 @@
  * @private
  */
 Document.prototype._getUidProvider = function() {
-    return this._uidProvider;
+	return this._uidProvider;
 }
 
-/**
- * Sets the NotificationListener for this document.
- *
- * @param listener The NotificationListener.
- * @private
- */
-Document.prototype._setNotificationListener = function( listener ) {
-	this._notificationListener = listener;
-}
 
-/**
- * Returns the NotificationListener for this document.
- *
- * @return The NotificationListener for this document or null if none is
- * set.
- * @private
- */
-Document.prototype._getNotificationListener = function() {
-	return this._notificationListener;
-}
-    
-/**
- * Impl level method for adding system specific listeners
- * 
- * @param listener
- * @private
- */
-Document.prototype._addSystemAttributeChangeListener = function( listener ) {
-	this._getSystemAttributeChangeListeners().addElement( listener );
-}
-	
-/**
- * Removes a system specific AttributeChangeListener
- * 
- * @param listener The listener object to remove from this Document
- * @return The removed listener or null
- * @private
- */
-Document.prototype._removeSystemAttributeChangeListener = function( listener ) {
-    return this._getSystemAttributeChangeListeners().removeElement( listener );
-}
-
-/**
- * Impl level method for adding system specific listeners
- * 
- * @param listener
- * @private
- */
-Document.prototype._addSystemStructureChangeListener = function( listener ) {
-    this._getSystemStructureChangeListeners().addElement( listener );
-}
-	
-/**
- * Impl level method for removing a system specific listener
- * 
- * @param listener
- * @return The removed listener or null
- * @private
- */
-Document.prototype._removeSystemStructureChangeListener = function ( listener ) {
-	return this._getSystemStructureChangeListeners().removeElement( listener );
-}
-	
-/**
- * Removes all system listeners
- * 
- * @private
- */
-Document.prototype._clearSystemListeners = function() {
-	if ( this._systemStructureChangeListeners != null ) {
-		this._systemStructureChangeListeners = new Vector();
-	}
-	if ( this._systemAttributeChangeListeners != null ) {
-		this._systemAttributeChangeListeners = new Vector();
-	}
-}
 
 /**
  * Returns the prefix associated with the specified namespace.
@@ -475,8 +324,8 @@
 	this._addIdToElementMapping( e.getAttribute( "id" ), e );
 	this._checkPrefixForCollisionAndRegister( e );
 	e._notifyListenersOnAddedToDocument( this );
-	for( var i=0; i < e.getChildCount(); i++ ) {
-		var o = e.getChildAt( i );
+	for( var i=0; i < e.childNodes.length; i++ ) {
+		var o = e.childNodes[i];
 		if (o.nodeType==google.DOM_ELEMENT_NODE){
 			this._addDocumentFragmentToIdMapAndCheckForPrefixCollisions( o );
 		}
@@ -489,8 +338,8 @@
 Document.prototype._removeDocumentFragmentFromIdMap = function( e ) {
 	this._idToElementMap[e.getAttribute( "id" )] = null;
 	e._notifyListenersOnRemovedFromDocument( this );
-	for( var i=0; i < e.getChildCount(); i++ ) {
-		var o = e.getChildAt( i );
+	for( var i=0; i < e.childNodes.length; i++ ) {
+		var o = e.childNodes[i];
 		if (o.nodeType==google.DOM_ELEMENT_NODE){
 			this._removeDocumentFragmentFromIdMap( o );
 		}
@@ -531,87 +380,24 @@
 }
 	
 
-/**
- * @private
- */            
-Document.prototype._getSystemStructureChangeListeners = function() {
-	if( this._systemStructureChangeListeners == null ) {
-		this._systemStructureChangeListeners = new Vector();
-	}
-	return this._systemStructureChangeListeners;
-}
-
-/**
- * @private
- */            
-Document.prototype._getSystemAttributeChangeListeners = function() {
-	if( this._systemAttributeChangeListeners == null ) {
-		this._systemAttributeChangeListeners = new Vector();
-	}
-	return this._systemAttributeChangeListeners;
-}
-
-/**
- * @private
- */            
-Document.prototype._getStructureChangeListeners = function() {
-	if( this._structureChangeListeners == null ) {
-		this._structureChangeListeners = new Vector();
-	}
-	return this._structureChangeListeners;
-}
-
-/**
- * @private
- */            
-Document.prototype._getAttributeChangeListeners = function() {
-	if( this._attributeChangeListeners == null ) {
-		this._attributeChangeListeners = new Vector();
-	}
-	return this._attributeChangeListeners;
-}
 
 /**
  * @private
  */            
 Document.prototype._removeExistingRoot = function() {
 	if ( this._rootElement != null ) {
-        var event = new StructureChangeEvent( null, this._rootElement );
-        // Just as in ElementImpl's notification of listeners at 
-        // the document level, use the notification listener around
-        // the user listeners only.
-        this._notifyListenersOfStructureChange
-            ( this._getSystemStructureChangeListeners(), event, Document.BEFORE_REMOVE );
-        if ( this._notificationListener != null ) {
-            this._notificationListener.beforeNotification();
-        }
-        try {
-            this._notifyListenersOfStructureChange
-                ( this._getStructureChangeListeners(), event, Document.BEFORE_REMOVE );
-        } finally {
-            if ( this._notificationListener != null ) {
-                this._notificationListener.afterNotification();
-            }
-        }
+		var event = new StructureChangeEvent( null, this._rootElement );
+  
+		this._notifyListenersOfStructureChange
+			( this._structureChangeListeners, event, Document.BEFORE_REMOVE );
+        
 		this._rootElement.setOwnerDocument( null );
 		this.removeChild(this._rootElement);
 		this._removeDocumentFragmentFromIdMap( this._rootElement );
-        // Just as in ElementImpl's notification of listeners at 
-        // the document level, use the notification listener around
-        // the user listeners only.
-        this._notifyListenersOfStructureChange
-            ( this._getSystemStructureChangeListeners(), event, Document.ON_REMOVE );
-        if ( this._notificationListener != null ) {
-            this._notificationListener.beforeNotification();
-        }
-        try {
-            this._notifyListenersOfStructureChange
-                ( this._getStructureChangeListeners(), event, Document.ON_REMOVE );
-        } finally {
-            if ( this._notificationListener != null ) {
-                this._notificationListener.afterNotification();
-            }
-        }
+         
+      this._notifyListenersOfStructureChange
+          ( this._structureChangeListeners, event, Document.ON_REMOVE );
+       
 	}
 }
 
@@ -620,8 +406,8 @@
  */            
 Document.prototype._notifyListenersOfStructureChange = function( v, e, type ) {
 	if ( v != null ) {
-		for ( var i = 0; i < v.size(); i ++ ) {
-        	var listener = v.elementAt( i );
+		for ( var i = 0; i < v.length; i ++ ) {
+        	var listener = v[i];
             switch ( type ) {
 	            case this.BEFORE_ADD:
                     listener.beforeChildAdded( e );
@@ -638,7 +424,7 @@
             }
             // Handle the case where the event causes the
             // listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
+            if ( v[i] != listener ) {
             	i = i - 1;
             }
         }

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=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/XapElement.js Thu Jul  6 14:31:03 2006
@@ -16,7 +16,9 @@
  */
  
 Xap.require("google.dom");
- /**
+Xap.require("xap.util.ArrayHelper");
+
+/**
  * @fileoverview An DOM element node implementation that supports
  * notification of changes.
  *
@@ -49,7 +51,7 @@
 	this._namespaceUri = null;
 	this._prefix = null;
     
-	// This vector is an alternating list of listner object and the listener
+	// This array is an alternating list of listner object and the listener
 	// class it was added as.
 	this._documentOwnershipListeners = null;
 	this._attributeChangeListeners = null;
@@ -100,6 +102,14 @@
 /** @private */
 XapElement.INDENT = "  ";
 
+XapElement.BEFORE_ATTRIBUTE_REMOVED = "beforeAttributeRemoved";
+XapElement.ON_ATTRIBUTE_REMOVED = "onAttributeRemoved";
+XapElement.BEFORE_ATTRIBUTE_SET = "beforeAttributeSet";
+XapElement.ON_ATTRIBUTE_SET = "onAttributeSet";
+XapElement.BEFORE_CHILD_REMOVED = "beforeChildRemoved";
+XapElement.BEFORE_CHILD_ADDED = "beforeChildAdded";
+XapElement.ON_CHILD_REMOVED= "onChildRemoved";
+XapElement.ON_CHILD_ADDED= "onChildAdded";
 
 
 
@@ -121,7 +131,6 @@
  * @private
  */
 XapElement.ENCODE_EVERYTHING_IN_ATTRIBUTES = 2;
-XapElement.EMPTY_VECTOR = new Vector(0);
 
 /** @private */
 XapElement.s_log = LogFactory.getLog( "DocumentObjectModel" );
@@ -199,7 +208,7 @@
     	this._doAnyAttributeChangeListenersExist( doc );
     if ( attributeChangeListenersExist ) {
 	    event = new AttributeChangeEvent( this, name, value );
-	    this._notifyListenersBeforeAttributeChange( doc, event );
+	    this._fireAttributeChangeEvent( doc, event, XapElement.BEFORE_ATTRIBUTE_SET);
 	    // Listeners have the opportunity to modify the value.
 	    // Make sure we get the latest value out of the event.
 	    value = event.getNewValue();
@@ -217,7 +226,7 @@
 	 google.XNode.prototype.setAttribute.call(this, name, value);
 	 
 	if ( attributeChangeListenersExist ) {
-		this._notifyListenersOnAttributeChange( doc, event );
+		this._fireAttributeChangeEvent( doc, event, XapElement.ON_ATTRIBUTE_SET);
 	}
 }
 
@@ -232,10 +241,12 @@
   	}
 	
    var event = new AttributeChangeEvent(this, name, null);
-   this._notifyListenersBeforeAttributeRemoval( doc, event );
+   
+   this._fireAttributeChangeEvent( doc, event, XapElement.BEFORE_ATTRIBUTE_REMOVED);
    // Actually perform the removal:
    google.XNode.prototype.removeAttribute.call(this, name);
-   this._notifyListenersOnAttributeRemoval( doc, event );
+   
+   this._fireAttributeChangeEvent( doc, event, XapElement.ON_ATTRIBUTE_REMOVED);
        
   	// We never allow elements not to have IDs - if the id attribute tries
 	// to be removed - remove it then reset it with one of our IDs
@@ -304,7 +315,7 @@
 	//notify listeners before the change takes place
 	if ( structureChangeListenerExists ) {
 		event = new StructureChangeEvent(this, child, index);
-		this._notifyListenersBeforeChildRemoved( doc, event );
+		this._fireStructureChangeEvent( doc, event, XapElement.BEFORE_CHILD_REMOVED);
 	}
 
 	//make the actual change
@@ -321,27 +332,13 @@
 	   
 	//notify listeners on attribute change
 	if ( structureChangeListenerExists ) {
-		this._notifyListenersOnChildRemoved( doc, event );
+		this._fireStructureChangeEvent( doc, event, XapElement.ON_CHILD_REMOVED);
 	}
 	
 	//TODO child here could be changed by the before event?
 	return child;
 }
 
-/**
- * Returns a vector of children, we should 
- * probably defeature this when convenient.
- */
-XapElement.prototype.getChildren = function() {
-	if (!this.childNodes || this.childNodes.length==0){
-		return XapElement.EMPTY_VECTOR;
-	}
-	var children = new Vector(this.childNodes.length);
-	for (var i = 0; i<this.childNodes.length;i++){
-		children.addElement(this.childNodes[i]);
-	}
-	return children;
-}
 
 /**
  * Returns the owner document. We should probably defeature
@@ -360,38 +357,6 @@
     return this._ownerDocument;
 }
 
-
-/**
- * Returns the equivalent of childNodes.length,
- * we should defeature this.
- */
-XapElement.prototype.getChildCount = function() {
-    return this.childNodes.length;
-}
-
-/**
- * Returns the equivalent of childNodes[i],
- * should defeature this.
- */
-XapElement.prototype.getChildAt = function( index ) {
-	return this.childNodes[index];
-}
-
-	
-/**
- * Returns the index of the given child
- * node, or -1 if the node is not a child
- */
-XapElement.prototype.indexOfChild = function ( child ) {
-    for (var i = 0; i < this.childNodes.length; i++) {
-   	 if (this.childNodes[i]==child){
-   	 	return i;
-   	 }
-    }
-    return -1;
-}
-
-
 /**
  * 
  * For compatibility with existing code we don't consider
@@ -429,29 +394,6 @@
 }
 
 /**
- * TODO this is pretty wacky with
- * the {...}
- */
-XapElement.prototype.getQName = function() {
-	var localName = this.getLocalName();
-	var prefix = this.getPrefix();
-	var namespaceUri = this.getNamespaceUri();
-    if( namespaceUri == null && prefix == null){
-        return localName;
-    }
-    
-    var sbuf = "";
-    
-    if( prefix!= null ) {
-        sbuf += prefix+ ":" + localName;
-    } else if( namespaceUri != null ) {
-        sbuf += "{" + namespaceUri + "}";
-        sbuf += localName;
-    }
-    return sbuf;
-}
-
-/**
  * Returns an XML string representing this element
  * and all children.
  * 
@@ -535,7 +477,7 @@
  * 
  */
 XapElement.prototype.addAttributeChangeListener = function ( listener ) {
-	this._getAttributeChangeListeners().addElement( listener );
+	this._getAttributeChangeListeners().push( listener );
 }
 
 /**
@@ -546,7 +488,7 @@
  * 
  */
 XapElement.prototype.removeAttributeChangeListener = function( listener ) {
-    this._getAttributeChangeListeners().removeElement( listener );
+	xap.util.ArrayHelper.removeElement( this._getAttributeChangeListeners(), listener );
 }
 
 /**
@@ -558,7 +500,7 @@
  * 
  */
 XapElement.prototype.addStructureChangeListener = function ( listener ) {
-    this._getStructureChangeListeners().addElement( listener );
+    this._getStructureChangeListeners().push( listener );
 }
 
 /**
@@ -569,7 +511,7 @@
  * 
  */
 XapElement.prototype.removeStructureChangeListener = function( listener ) {
-    this._getStructureChangeListeners().removeElement( listener );
+	xap.util.ArrayHelper.removeElement( this._getStructureChangeListeners(), listener );
 }
 
 /**
@@ -581,7 +523,7 @@
  * 
  */
 XapElement.prototype.addDocumentOwnershipListener = function( listener ) {
-	this._getDocumentOwnershipListeners().addElement( listener );
+	this._getDocumentOwnershipListeners().push( listener );
 }
 
 /**
@@ -592,7 +534,7 @@
  * 
  */
 XapElement.prototype.removeDocumentOwnershipListener = function( listener) {
-	this._getDocumentOwnershipListeners().removeElement( listener );
+	xap.util.ArrayHelper.removeElement( this._getDocumentOwnershipListeners(), listener );
 }
 
 
@@ -637,7 +579,7 @@
 	if (oldNode){		
 		//TODO this is somewhat inneficient as the superclass
 		//insertBefore does this same lookup
-		index = this.indexOfChild(oldNode);
+		index = xap.util.ArrayHelper.indexOf(this.childNodes, oldNode);
 		if (index==-1){
 			return null; //TODO exception?
 		}
@@ -650,7 +592,7 @@
 	
 	if ( structureChangeListenersExist ) {
 		event = new StructureChangeEvent( this, newNode, index );
-		this._notifyListenersBeforeChildAdded( doc, event );
+		this._fireStructureChangeEvent( doc, event, XapElement.BEFORE_CHILD_ADDED);
 		// The listeners have the opportunity to modify what is getting 
 		// added, so make sure that what we add is the subtree on the 
 		// event, not the element passed to this method.
@@ -700,7 +642,7 @@
    }
     
 	if ( structureChangeListenersExist ) {
-		this._notifyListenersOnChildAdded( doc, event );
+		this._fireStructureChangeEvent( doc, event, XapElement.ON_CHILD_ADDED);
 	}
 	return newNode;    
 }
@@ -743,62 +685,45 @@
 
 /** @private */
 XapElement.prototype._notifyListenersOnRemovedFromDocument = function( doc ) {
-	if ( doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-    	var listeners = this._getDocumentOwnershipListeners();
-        for ( var i = 0; i < listeners; i++ ) {
-            var listener = listeners.elementAt( i );
-            try {
-            	listener.onRemovedFromDocument( doc );
-                // Handle the case where the event causes the
-                // listener to remove itself.
-                if ( listeners.elementAt( i ) != listener ) {
- 	               i = i - 1;
-                }
-            } catch ( t ) {
-            	XapElement.s_log.exception
-                        ( ResourceDictionary.getMessage
-                          ( XapElement.DOC_OWNERSHIP_FAILURE, 
-                          XapElement.CLASSNAME ), t );
-            }
-        }
-    } finally {
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
+
+ 	var listeners = this._getDocumentOwnershipListeners();
+	for ( var i = 0; i < listeners.length; i++ ) {
+      var listener = listeners[ i ];
+      try {
+      	listener.onRemovedFromDocument( doc );
+          // Handle the case where the event causes the
+          // listener to remove itself.
+          if ( listeners[i] != listener ) {
+            i = i - 1;
+          }
+      } catch ( t ) {
+      	XapElement.s_log.exception
+                  ( ResourceDictionary.getMessage
+                    ( XapElement.DOC_OWNERSHIP_FAILURE, 
+                    XapElement.CLASSNAME ), t );
+      }
+	}  
 }
 
 /** @private */
 XapElement.prototype._notifyListenersOnAddedToDocument = function( doc ) {
-	if ( doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        var listeners = this._getDocumentOwnershipListeners();
-        for ( var i = 0; i < listeners.size(); i++ ) {
-            var listener = listeners.elementAt( i );
-            try {
-                listener.onAddedToDocument(doc);
-                // Handle the case where the event causes the
-                // listener to remove itself.
-                if ( listeners.elementAt( i ) != listener ) {
-                	i = i - 1;
-                }
-            } catch ( t ) {
-            	XapElement.s_log.exception
-                        ( ResourceDictionary.getMessage
-                          ( XapElement.DOC_OWNERSHIP_FAILURE, 
-                            XapElement.CLASSNAME ), t );
-            }
-        }
-    } finally {
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
+     var listeners = this._getDocumentOwnershipListeners();
+     for ( var i = 0; i < listeners.length; i++ ) {
+         var listener = listeners[i];
+         try {
+             listener.onAddedToDocument(doc);
+             // Handle the case where the event causes the
+             // listener to remove itself.
+             if ( listeners[i] != listener ) {
+             	i = i - 1;
+             }
+         } catch ( t ) {
+         	XapElement.s_log.exception
+                     ( ResourceDictionary.getMessage
+                       ( XapElement.DOC_OWNERSHIP_FAILURE, 
+                         XapElement.CLASSNAME ), t );
+         }
+     }
 }
 
 //-----------------------------------------------------------------------
@@ -808,7 +733,7 @@
 /** @private */
 XapElement.prototype._getAttributeChangeListeners = function() {
 	if( this._attributeChangeListeners == null ) {
-		this._attributeChangeListeners = new Vector();
+		this._attributeChangeListeners = new Array();
 	}
 	return this._attributeChangeListeners;
 }
@@ -816,7 +741,7 @@
 /** @private */
 XapElement.prototype._getStructureChangeListeners = function() {
 	if( this._structureChangeListeners == null ) {
-		this._structureChangeListeners = new Vector();
+		this._structureChangeListeners = new Array();
 	}
 	return this._structureChangeListeners;
 }
@@ -824,7 +749,7 @@
 /** @private */
 XapElement.prototype._getDocumentOwnershipListeners = function() {
 	if( this._documentOwnershipListeners == null ) {
-		this._documentOwnershipListeners = new Vector();
+		this._documentOwnershipListeners = new Array();
 	}
 	return this._documentOwnershipListeners;
 }
@@ -851,7 +776,7 @@
         sbuf += XmlUtils.encode( node.nodeValue );
     } else {
         if ( prettyPrint && node.getParent() != null ) {
-        	var index = node.getParent().indexOfChild( node );
+        	var index = xap.util.ArrayHelper.indexOf(node.getParent().childNodes, node );
         	if ( index == -1 ) { // NOPMD
         	    // I added this because the if clause below throws 
         	    // an OutOfBounds exception when toXml is called inside
@@ -859,7 +784,7 @@
         	} else {
         		 //var child = node.getParent().getChildAt(index-1);
         		 if ( index == 0 || 
-        		 	( node.getParent().getChildAt(index-1).nodeType==google.DOM_ELEMENT_NODE)) {
+        		 	( node.getParent().childNodes[index-1].nodeType==google.DOM_ELEMENT_NODE)) {
         	    	sbuf += '\n';
         	    	XapElement._writeIndent( sbuf, indent );
         		 }
@@ -940,14 +865,14 @@
 		}
 		
 		//add children if there are any
-		if ( node.getChildCount() == 0 ) {
+		if ( node.childNodes.length == 0 ) {
 			sbuf += "/>";
 		}
 		else {
 			sbuf += '>';
 			var elementHasTextNode = false;
-			for ( var i = 0; i < node.getChildCount(); i++ ) {
-				var child = node.getChildAt(i);
+			for ( var i = 0; i < node.childNodes.length; i++ ) {
+				var child = node.childNodes[i];
 				if( child.nodeType == google.DOM_TEXT_NODE ) {
 					elementHasTextNode = true;
 				}
@@ -977,477 +902,76 @@
 }
 
 
-//TODO all these notify methods are horrible, this entire
-//listener scheme is horrendous
-
-/**
- * @private
- * @param doc The Document where the event occured
- * @param event StructureChangeEvent
- * 
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeChildAdded = function( doc, event ) {
-    if ( doc != null ) {
-	    this._notifyListenersBeforeChildAddedHelper
-            (doc._getSystemStructureChangeListeners(), event);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersBeforeChildAddedHelper
-                (doc._getStructureChangeListeners(), event);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersBeforeChildAddedHelper( 
-        						   this._getStructureChangeListeners(), event );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
-}
-
-/**
- * @private
- * @param listeners The listeners vector
- * @param event The StructureChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeChildAddedHelper = function ( listeners, event ) {
-    if( listeners != null ) {
-	    for( var i=0; i < listeners.size(); i++ ) {
-        	var listener = listeners.elementAt( i );
-            listener.beforeChildAdded( event );
-            // Handle the case where the event causes the
-            // listener to remove itself.
-            if ( listeners.elementAt( i ) != listener ) {
-               i = i - 1;
-            }
-        }
-    }
-}
-
-/**
- * @private
- * @param doc
- * @param event The StructureChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeChildRemoved = function( doc, event ) {
-    if ( doc != null ) {
-	    this._notifyListenersBeforeChildRemovedHelper
-            (doc._getSystemStructureChangeListeners(), event);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersBeforeChildRemovedHelper(
-            								doc._getStructureChangeListeners(), event);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersBeforeChildRemovedHelper( 
-        						this._getStructureChangeListeners(), event );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
-}
-
-/**
- * @private
- * @param v The vector of listeners
- * @param e The StructureChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeChildRemovedHelper = function( v, e ) {
-    if ( v != null ) {
-        for( var i=0; i < v.size(); i++ ) {
-        	var listener = v.elementAt( i );
-	        listener.beforeChildRemoved(e);
-            if ( v.elementAt( i ) != listener ) {
-                    i = i - 1;
-            }
-        }
-    }
-}
-
-/**
- * @private
- * @param doc
- * @param event The StructureChangeEvent
- */    
-XapElement.prototype._notifyListenersOnChildAdded = function ( doc, event ) {
-    if ( doc != null ) {
-	    this._notifyListenersOnChildAddedHelper
-            (doc._getSystemStructureChangeListeners(), event);
-            
-
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersOnChildAddedHelper(
-            							doc._getStructureChangeListeners(), event );
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    
-    
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersOnChildAddedHelper( 
-        						 this._getStructureChangeListeners(), event );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
-}
-
-/**
- * @private
- * @param v The vector of listeners
- * @param e The StructureChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersOnChildAddedHelper = function( v, e ) {
-    if( v != null ) {
-        for( var i=0; i < v.size(); i++ ) {
-        	var listener = v.elementAt( i );
-            listener.onChildAdded( e );
-            // Handle the case where the event causes the
-          	// listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
-            	i = i - 1;
-            }
-        }
-    }
-}
-
-/**
- * @private
- * @param doc The document
- * @param event The StructureChangeEvent
- */
-XapElement.prototype._notifyListenersOnChildRemoved = function( doc, event ) {
-    if ( doc != null ) {
-	    this._notifyListenersOnChildRemovedHelper
-            (doc._getSystemStructureChangeListeners(), event);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersOnChildRemovedHelper
-                (doc._getStructureChangeListeners(), event);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersOnChildRemovedHelper( 
-        						this._getStructureChangeListeners(), event );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
+XapElement.prototype._fireStructureChangeEvent = function( doc, event, methodName){
+	if (doc){
+		this._notifyListeners(doc._structureChangeListeners,
+			event, methodName);
+	}
+	
+	this._notifyListeners(this._getStructureChangeListeners(), event, methodName);	
 }
 
-/**
- * @private
- * @param e The StructureChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersOnChildRemovedHelper = function ( v, e ) {
-    if( v != null ) {
-	    for( var i=0; i < v.size(); i++ ) {
-	    	var listener = v.elementAt( i );
-            listener.onChildRemoved( e );
-            // Handle the case where the event causes the
-            // listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
-                i = i - 1;
-        	}
-        }
-    }
-}
 
-/**
- * @private
- * @param doc
- * @param e The AttributeChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeAttributeChange = function( doc, e ) {
-    if ( doc != null ) {
-	    this._notifyListenersBeforeAttributeChangeHelper
-            (doc._getSystemAttributeChangeListeners(), e);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersBeforeAttributeChangeHelper
-                (doc._getAttributeChangeListeners(), e);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersBeforeAttributeChangeHelper( 
-        							this._getAttributeChangeListeners(), e );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
+XapElement.prototype._fireAttributeChangeEvent = function( doc, event, methodName){
+	if (doc){
+		this._notifyListeners(doc._attributeChangeListeners,
+			event, methodName);
+	}
+	
+	this._notifyListeners(this._getAttributeChangeListeners(), event, methodName);	
 }
 
-/**
- * @private
- * @param v The vector of listeners
- * @param e The AttributeChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeAttributeChangeHelper = function( v, e ) {
-    if( v != null ) {
-        for( var i=0; i < v.size(); i++ ) {
-        	var listener = v.elementAt(i);
-            listener.beforeAttributeSet( e );
-            // Handle the case where the event causes the
-            // listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
-                i = i - 1;
-        	}
-        }
-    }
-}
 
-/**
- * @private
- * @param doc 
- * @param event The AttributeChangeEvent
- */
-XapElement.prototype._notifyListenersOnAttributeChange = function( doc, event ) {
-    if ( doc != null ) {
-	    this._notifyListenersOnAttributeChangeHelper
-            (doc._getSystemAttributeChangeListeners(), event);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersOnAttributeChangeHelper
-                (doc._getAttributeChangeListeners(), event);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersOnAttributeChangeHelper( 
-        						this._getAttributeChangeListeners(), event );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
-}
 
-/**
- * @private
- * @param v The vector of listeners
- * @param e The AttributeChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersOnAttributeChangeHelper = function( v, e ) {
-    if( v != null ) {
-	    for( var i=0; i < v.size(); i++ ) {
-        	var listener = v.elementAt( i );
-            listener.onAttributeSet( e );
-            // Handle the case where the event causes the
-            // listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
-                i = i - 1;
-        	}
-        }
-    }
-}
 
 /**
  * @private
- * @param doc The Document
- * @param e The AttributeChangeEvent
+ * @param listeners The array of listeners
+ * @param event The event to fire.
+ * @param methodName The name of the event to fire
  * @throws ChangeRejectedException
  */
-XapElement.prototype._notifyListenersBeforeAttributeRemoval = function( doc, e ) {
-    if ( doc != null ) {
-		this._notifyListenersBeforeAttributeRemovalHelper
-            (doc._getSystemAttributeChangeListeners(), e);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersBeforeAttributeRemovalHelper
-                (doc._getAttributeChangeListeners(), e);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersBeforeAttributeRemovalHelper( 
-        							this._getAttributeChangeListeners(), e );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
-}
-
-/**
- * @private
- * @param v
- * @param e The AttributeChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersBeforeAttributeRemovalHelper = function( v, e ) {
-    if(	v != null ) {
-	    for( var i=0; i < v.size(); i++ ) {
-        	var listener = v.elementAt( i );
-            listener.beforeAttributeRemoved( e );
-            // Handle the case where the event causes the
-            // listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
-                i = i - 1;
-        	}
-        }
-    }
+XapElement.prototype._notifyListeners = function( listeners, event, methodName){
+	if (!listeners) return;
+	
+	for (var i =0; i<listeners.length; i++){
+		var listener = listeners[i];
+		
+		//TODO check for existence?
+		listener[methodName].call(listener, event);
+		
+		if ( listeners[i] != listener ) {
+			i = i - 1;
+     	}
+	}
 }
 
-/**
- * @private
- * @param doc
- * @param e The AttributeChangeEvent
- */
-XapElement.prototype._notifyListenersOnAttributeRemoval = function ( doc, e ) {
-    if ( doc != null ) {
-	    this._notifyListenersOnAttributeRemovalHelper
-            (doc._getSystemAttributeChangeListeners(), e);
-        if ( doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().beforeNotification();
-        }
-        try {
-            this._notifyListenersOnAttributeRemovalHelper
-                (doc._getAttributeChangeListeners(), e);
-        } finally {
-            if ( doc._getNotificationListener() != null ) {
-                doc._getNotificationListener().afterNotification();
-            }
-        }
-    }
-    if ( doc != null && doc._getNotificationListener() != null ) {
-        doc._getNotificationListener().beforeNotification();
-    }
-    try {
-        this._notifyListenersOnAttributeRemovalHelper( 
-        								this._getAttributeChangeListeners(), e );
-    } finally {
-        if ( doc != null && doc._getNotificationListener() != null ) {
-            doc._getNotificationListener().afterNotification();
-        }
-    }
-}
 
-/**
- * @private
- * @param v The Vector of listeners
- * @param e The AttributeChangeEvent
- * @throws ChangeRejectedException
- */
-XapElement.prototype._notifyListenersOnAttributeRemovalHelper = function( v, e ) {
-    if ( v != null ) {
-        for ( var i = 0; i < v.size(); i ++ ) {
-        	var listener = v.elementAt( i );
-            listener.onAttributeRemoved( e );
-            // Handle the case where the event causes the
-         	// listener to remove itself.
-            if ( v.elementAt( i ) != listener ) {
-                i = i - 1;
-        	}
-        }
-    }
-}
 
 /** @private */
 XapElement.prototype._doAnyAttributeChangeListenersExist = function( doc ) {
 	var normalListeners = null;
-	var systemListeners = null;
 	if ( doc != null ) {
-		normalListeners = doc._getAttributeChangeListeners();
-		systemListeners = doc._getSystemAttributeChangeListeners();
+		normalListeners = doc._attributeChangeListeners;
 	}
     
     var thisElementsAttributeListeners =  this._getAttributeChangeListeners() ;
     
 	return (thisElementsAttributeListeners != null 
-                && thisElementsAttributeListeners.size() > 0 
+                && thisElementsAttributeListeners.length > 0 
                 ) ||
-				  ( normalListeners != null && normalListeners.size() > 0 ) ||
-		          ( systemListeners != null && systemListeners.size() > 0 );
+				  ( normalListeners != null && normalListeners.length > 0 );
 }
 
 /** @private */
 XapElement.prototype._doAnyStructureChangeListenersExist = function( doc ) {
 	var normalListeners = null;
-	var systemListeners = null;
 	if ( doc != null ) {
-		normalListeners = doc._getStructureChangeListeners();
-		systemListeners = doc._getSystemStructureChangeListeners();
+		normalListeners = doc._structureChangeListeners;
 	} 
 	
-	return this._getStructureChangeListeners().size() > 0 ||
-          ( normalListeners != null && normalListeners.size() > 0 ) ||
-          ( systemListeners != null && systemListeners.size() > 0 );
+	return this._getStructureChangeListeners().length > 0 ||
+          ( normalListeners != null && normalListeners.length > 0 );
 }
 
 
@@ -1455,70 +979,6 @@
 // Array Helpers.
 //-----------------------------------------------------------------------
 
-/** @private */
-XapElement.prototype._indexOf = function ( value, array ) {
-    if ( value == null || array == null ) {
-        return -1;
-    }
-    for ( var i = 0; i < array.length && array[i] != null; i++ ) {
-        if ( value == array[i] ) {
-            return i;
-        }
-    }
-    return -1;
-}
-
-/** @private */
-XapElement.prototype._indexOfKey = function( key, array, start ) {
-    if ( key == null || array == null ) {
-        return -1;
-    }
-    if ( start == null ) {
-    	start = 0;
-    }
-    
-    for ( var i = start; i < array.length && array[i] != null; ) {
-        if ( key == array[i] ) {
-            return i;
-        }
-        i = i + 2;
-    }
-    return -1;
-}
-
-/** @private */
-XapElement.prototype._removePairStartingAtIndexAndReturnLastKey = function ( index, array ) {
-    if ( index + 1 >= array.length || index < 0 ) {
-        throw new IllegalStateException
-            ( ResourceDictionary.getMessage
-              ( XapElement.CANT_REMOVE_KEY_VALUE_PAIR_FROM_ARRAY,
-                XapElement.CLASSNAME,
-                new Array( array.length, index )));
-    }
-    var lastIndex = index - 2;
-    array[index] = null;
-    array[index + 1] = null;
-
-    for ( var i = index + 2; i + 1 < array.length && array[i] != null; ) {
-        array[i - 2] = array[i];
-        array[i - 1] = array[i + 1];
-        array[i] = null;
-        array[i + 1] = null;
-        lastIndex = i - 2;
-        i = i + 2;
-    }
-    return lastIndex;
-}
-
-/** @private */
-XapElement.prototype._ensureCapacityForPair = function( array ) {
-    if ( array[ array.length - 2 ] != null ) {
-        // Making room for six more attributes or listeners.
-        var newArray = array.concat( new Array( 6*2 ) );
-        return newArray;
-    }
-    return array;
-}
 
 
 /** @private */
@@ -1560,8 +1020,8 @@
 		return e;
 	}
 
-	for ( var i = 0; i < this.getChildCount(); i++ ) {
-		var o = this.getChildAt(i);
+	for ( var i = 0; i < this.childNodes.length; i++ ) {
+		var o = this.childNodes[i];
 		if (o.nodeType==google.DOM_ELEMENT_NODE){
 			var childCopy = o._cloneHelper( deep, withIds, parser );
 			e.appendChild( childCopy );

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=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js Thu Jul  6 14:31:03 2006
@@ -587,24 +587,16 @@
 
         parent = currentNode.parentNode ;
 
-        if (currentNode.nodeType == google.DOM_ELEMENT_NODE) {
-            if ( parent != null ) {
-                // No longer necessary or appropriate,
-                // given that the concept of inserting at an
-                // index appears to have been decprecated in
-                // favour of inserting before a named element.
-                //
-                //index = parent.getChildren().indexOf(currentNode) + 1;
-            } else {
+        if (currentNode.nodeType == google.DOM_ELEMENT_NODE ||
+         	currentNode.nodeType == google.DOM_TEXT_NODE) {
+            if ( parent == null ) {
                 throw new XmodifyException(
                         XmodifyException.INVALID_INSERT_AFTER_BECAUSE_OF_PARENT, 
                         "'undefined'"
                             )
-            };
-
-        } else if (currentNode.nodeType == google.DOM_TEXT_NODE) {
-            index = parent.getChildren().indexOf(currentNode) + 1;
-        } else if (currentNode.nodeType == google.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
@@ -650,23 +642,14 @@
 
         parent = currentNode.parentNode ;
 
-        if (currentNode.nodeType == google.DOM_ELEMENT_NODE) {
-            if ( parent != null ) {
-                // No longer necessary or appropriate,
-                // given that the concept of inserting at an
-                // index appears to have been decprecated in
-                // favour of inserting before a named element.
-                //
-                //index = parent.getChildren().indexOf(currentNode) + 1;
-            } else {
+        if (currentNode.nodeType == google.DOM_ELEMENT_NODE ||
+         	currentNode.nodeType == google.DOM_TEXT_NODE) {
+            if ( parent == null ) {
                 throw new XmodifyException(
                         XmodifyException.INVALID_INSERT_AFTER_BECAUSE_OF_PARENT, 
                         "'undefined'"
                             )
-            };
-
-        } else if (currentNode.nodeType == google.DOM_TEXT_NODE) {
-            index = parent.getChildren().indexOf(currentNode) + 1;
+            }
         } 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

Modified: incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/DirectiveSet.js Thu Jul  6 14:31:03 2006
@@ -16,15 +16,8 @@
  */
  
  
-DirectiveSet = function(elemDirectives)
-{
-// The only hinky thing about this is the lack of a good Array-to-Vector
-// method, which in turn we need because we're unable to overload 
-// the _createDirectives method to accept either an array or a Vector:
-	var arrCommands = elemDirectives.getChildren();
-
-    var modElement = arrCommands['getFirstElement']();
-	this._directives  = this._createDirectives(modElement.parentNode.getChildren());
+DirectiveSet = function( modificationsElement ){
+	this._directives  = this._createDirectives(modificationsElement.childNodes);
 }
 
 DirectiveSet.prototype.execute = function(uiDocument)
@@ -43,10 +36,10 @@
    var dirs = new Array();
 
    for (var i = 0;
-        i < elemsDirectives.size();
+        i < elemsDirectives.length;
         i++)
        {
-          dirs[dirs.length] = new CommandDirective (elemsDirectives.elementAt(i));
+          dirs[dirs.length] = new CommandDirective (elemsDirectives[i]);
 
        } /* end for i */
 

Modified: incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/Xmodify.js Thu Jul  6 14:31:03 2006
@@ -75,10 +75,9 @@
  * @version Modeled after Java $Revision: 1.20 $
  */
 
-Xmodify = function(dom_CommandsDocRoot)
+Xmodify = function( modificationsElement )
 {
-   this.commandsDocRoot = dom_CommandsDocRoot;
-   this._directiveSet = new DirectiveSet(this.commandsDocRoot);
+   this._directiveSet = new DirectiveSet(modificationsElement);
    var checkThisOutOnDebugging = true ; 
 }
 

Modified: incubator/xap/trunk/testsrc/XapUnitTestSuite.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/XapUnitTestSuite.html?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/testsrc/XapUnitTestSuite.html (original)
+++ incubator/xap/trunk/testsrc/XapUnitTestSuite.html Thu Jul  6 14:31:03 2006
@@ -10,7 +10,6 @@
 
 	    function utilSuite( webappContext ) {
             var result = new top.jsUnitTestSuite();
-            result.addTestPage( webappContext + "/testsrc/xap/util/_TestVector.html" );
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestHashtable.html" );
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestLogFactory.html" );
             result.addTestPage( webappContext + "/testsrc/xap/util/_TestCharacter.html" );

Modified: incubator/xap/trunk/testsrc/xap/xml/_TestDocument.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/xml/_TestDocument.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/testsrc/xap/xml/_TestDocument.js (original)
+++ incubator/xap/trunk/testsrc/xap/xml/_TestDocument.js Thu Jul  6 14:31:03 2006
@@ -31,15 +31,11 @@
 	assertTrue( "doc.addAttributeChangeListener", doc.addAttributeChangeListener != null );
 	assertTrue( "doc._addDocumentFragmentToIdMapAndCheckForPrefixCollisions", doc._addDocumentFragmentToIdMapAndCheckForPrefixCollisions != null );
 	assertTrue( "doc._addIdToElementMapping", doc._addIdToElementMapping != null );
-	assertTrue( "doc._addSystemAttributeChangeListener", doc._addSystemAttributeChangeListener != null );
-	assertTrue( "doc._addSystemStructureChangeListener", doc._addSystemStructureChangeListener != null );
 	assertTrue( "doc.addStructureChangeListener", doc.addStructureChangeListener != null );
 	assertTrue( "doc._checkPrefixForCollisionAndRegister", doc._checkPrefixForCollisionAndRegister != null );
-	assertTrue( "doc._clearSystemListeners", doc._clearSystemListeners != null );
 	assertTrue( "doc.createElement", doc.createElement != null );
 	assertTrue( "doc.getElementById", doc.getElementById != null );
 	assertTrue( "doc._getNamespaceForPrefix", doc._getNamespaceForPrefix != null );
-	assertTrue( "doc._getNotificationListener", doc._getNotificationListener != null );
 	assertTrue( "doc", doc._getPrefixForNamespace != null );
 	assertTrue( "doc.getRootElement", doc.getRootElement != null );
 	assertTrue( "doc._getUidProvider", doc._getUidProvider != null );
@@ -48,10 +44,7 @@
 	assertTrue( "doc.removeAttributeChangeListener", doc.removeAttributeChangeListener != null );
 	assertTrue( "doc._removeDocumentFragmentFromIdMap", doc._removeDocumentFragmentFromIdMap != null );
 	assertTrue( "doc._removeExistingRoot", doc._removeExistingRoot != null );
-	assertTrue( "doc._removeSystemAttributeChangeListener", doc._removeSystemAttributeChangeListener != null );
-	assertTrue( "doc._removeSystemStructureChangeListener", doc._removeSystemStructureChangeListener != null );
 	assertTrue( "doc.removeStructureChangeListener", doc.removeStructureChangeListener != null );
-	assertTrue( "doc._setNotificationListener", doc._setNotificationListener != null );
 	assertTrue( "doc.setRootElement", doc.setRootElement != null );
 	assertTrue( "doc.toString", doc.toString != null );
 	assertTrue( "doc._toStringHelper", doc._toStringHelper != null );
@@ -91,7 +84,7 @@
 	var obj = new Object();
 	obj.prototype = new StructureChangeListener();
 	doc.addStructureChangeListener( obj );
-	assertTrue( doc._structureChangeListeners.size() == 1 );
+	assertTrue( doc._structureChangeListeners.length== 1 );
 	doc.removeStructureChangeListener( obj );
-	assertTrue( doc._structureChangeListeners.size() == 0 );
+	assertTrue( doc._structureChangeListeners.length == 0 );
 }

Modified: incubator/xap/trunk/testsrc/xap/xml/_TestElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/xml/_TestElement.js?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/testsrc/xap/xml/_TestElement.js (original)
+++ incubator/xap/trunk/testsrc/xap/xml/_TestElement.js Thu Jul  6 14:31:03 2006
@@ -45,23 +45,15 @@
 	assertTrue( "el.deepClone", el.deepClone != null );
 	assertTrue( "el._doAnyAttributeChangeListenersExist", el._doAnyAttributeChangeListenersExist != null );
 	assertTrue( "el._doAnyStructureChangeListenersExist", el._doAnyStructureChangeListenersExist != null );
-	assertTrue( "el._ensureCapacityForPair", el._ensureCapacityForPair != null );
 	assertTrue( "el.getAttribute", el.getAttribute != null );
-	assertTrue( "el.getChildAt", el.getChildAt != null );
-	assertTrue( "el.getChildCount", el.getChildCount != null );
 	assertTrue( "el.getLocalName", el.getLocalName != null );
 	assertTrue( "el.getNamespaceUri", el.getNamespaceUri != null );
 	assertTrue( "el.getOwnerDocument", el.getOwnerDocument != null );
 	assertTrue( "el.getParent", el.getParent != null );
 	assertTrue( "el.getPrefix", el.getPrefix != null );
-	assertTrue( "el.getQName", el.getQName != null );
-	assertTrue( "el._indexOf", el._indexOf != null );
-	assertTrue( "el.indexOfChild", el.indexOfChild != null );
-	assertTrue( "el._indexOfKey", el._indexOfKey != null );
 	assertTrue( "el.removeAttributeChangeListener", el.removeAttributeChangeListener != null );
 	assertTrue( "el.removeChild", el.removeChild != null );
 	assertTrue( "el.removeDocumentOwnershipListener", el.removeDocumentOwnershipListener != null );
-	assertTrue( "el._removePairStartingAtIndexAndReturnLastKey", el._removePairStartingAtIndexAndReturnLastKey != null );
 	assertTrue( "el.removeStructureChangeListener", el.removeStructureChangeListener != null );
 	assertTrue( "el.setAttribute", el.setAttribute != null );
 	assertTrue( "el.toString", el.toString != null );

Modified: incubator/xap/trunk/testsrc/xap/xml/_TestParser.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/testsrc/xap/xml/_TestParser.html?rev=419707&r1=419706&r2=419707&view=diff
==============================================================================
--- incubator/xap/trunk/testsrc/xap/xml/_TestParser.html (original)
+++ incubator/xap/trunk/testsrc/xap/xml/_TestParser.html Thu Jul  6 14:31:03 2006
@@ -74,7 +74,7 @@
     function assertEntitiesResolved(xmlString, resolvedEntitiesString){
         var doc = createDoc(xmlString);
         var root = doc.getRootElement();
-        var child = root.getChildAt(0);
+        var child = root.childNodes[0];
 
         assertEquals("Entities in attributes were not resolved correctly.",
                 resolvedEntitiesString,
@@ -82,7 +82,7 @@
                 );   
         assertEquals("Entities in text node were not resolved correctly.",
                 resolvedEntitiesString,
-                child.getChildAt(0).nodeValue
+                child.childNodes[0].nodeValue
                 );
     }
 
@@ -142,17 +142,17 @@
     	var outStr = "" ;
 
     	assertEquals("The root element should have three children.", 
-    			doc.getRootElement().getChildCount(), 3);
+    			doc.getRootElement().childNodes.length, 3);
     	
     	assertEquals("The first child should be a text node.", 
-    			doc.getRootElement().getChildAt(0).nodeValue, "'I am text'");
+    			doc.getRootElement().childNodes[0].nodeValue, "'I am text'");
     	expected = "'I am CDATA'";
-    	outStr += ("[" + doc.getRootElement().getChildAt(1) + "]");
+    	outStr += ("[" + doc.getRootElement().childNodes[1]+ "]");
     	outStr += ("[" + expected + "]");
     	assertEquals("The second child should be a CDATA node.", 
-    			doc.getRootElement().getChildAt(1).nodeValue, expected);
+    			doc.getRootElement().childNodes[1].nodeValue, expected);
     	assertEquals("The third child should be a text node.", 
-    			doc.getRootElement().getChildAt(2).nodeValue, "'I am another text'");
+    			doc.getRootElement().childNodes[2].nodeValue, "'I am another text'");
     }
 		
 /**
@@ -170,10 +170,10 @@
 	
 		assertFalse(exceptionThrown) ;	
 /* Breaks unit test coherence....
-	    assertEquals(doc.getRootElement().getChildAt(0).getChildAt(9).getAttribute("role"),
+	    assertEquals(doc.getRootElement().childNodes[0].childNodes[9].getAttribute("role"),
 	    				"Sales Guy"
 	    				)
-	    assertEquals(doc.getRootElement().getChildAt(0).getChildAt(1).getAttribute("name"),
+	    assertEquals(doc.getRootElement().childNodes[0].childNodes[1].getAttribute("name"),
 	    				"Coach K. Wei"
 	    				)	    				
 */	    				



Mime
View raw message