xModify Processors

The XAP project has created several xModify processors (jQuery, Prototype, MooTools and XAP) to handle the execution of xModify operations. Included in the XAP core functionality is the ability to execute xModify scripts against either the HTML or UI DOMs.

HTML Blending

xModify provides a lot of flexibility and power to dynamicaly change the HTML DOM, but can sometimes be more than is needed. HTML blending is simpler way to do modify the HTML DOM. Each processor has a blend function that executes a request then based on the "selector" and "mode" parameters will blend in the HTML returned from the request.

"Selectors" - refer to the underlying selector functionality of the library.
"Mode" can be "replace", "insert-after", "insert-before", "replace-children", "append"

xModify for jQuery

jQuery Home Page:
www.jquery.com
xModify Extension:
xmodify-jquery.js (Uncompressed) (9 KB)
xmodify-jquery-compressed.js (Compressed) (3 KB)
xModify Usage:

You will need to include the latest jQuery library (Download) and the xModify extension.

						
 <script language="JavaScript" type="text/javascript" 
	src="javascript/jquery/jquery-latest.js"></script>
	
 <script language="JavaScript" type="text/javascript" 
	src="javascript/xmodify/xmodify-jquery.js"></script>
	

Call the xModify function from JavaScript, once called the xModify processor uses the jQuery.ajax function to request the url and then process the response. You will need to typically send information to the server-side resource using a POST or GET. To do this append the parameters to the end of the url string, for example: {url:'login.jsp?username='+usernameValue+'password='+passwordValue});

							
 $.xmodify({url:'xModify-Document.xml'});

Node Selectors:
The select attribute of the xModify operations is as defined on the following page.

Selectors Details

The operations will hand off the "select" attribute to the $(select-attribute-value).

HTML Blending:
    var selector = "#myDiv";
    var mode = "append"; //append, replace, replace-children, insert-before, insert-after
    $.blend({ 
            url: "blend.html",
            complete: function(results, request){
                //function will be called after the xmodify 
                //processing is finished
            }
    }, selector, mode);
	
xModify for XAP

XAP Home Page:
incubator.apache.org/xap
xModify Extension:
xapcore-min.js (Uncompressed) (228 KB)
XapConfig-Min.js (Compressed) (4 KB)
xModify Usage:


 <script language="JavaScript" type="text/javascript" 
	src="javascript/xmodify/xapcore-min.js"></script>

  <script>
     var myApp = null;
	
	 //When the windows on load function is called 
	 //create the XAP application.  Keep a reference
	 //to the application.
     window.onload = function(){
         myApp = Xap.createApplication({
		               configFilePath:'javascript/xap/XapConfig-Min.js',
					   element:null
                 });
     }
  </script>

Call the xModify function from JavaScript, once called the xModify processor uses the XAP underyling communication functionality to request the url and then process the response.

							
 myApp.fireEvent('xModify-Document.xml');

Node Selectors:
The select attribute of the xModify operations when using XAP can be any XPATH 1.0 statement. The underlying implementation uses Google XPath parser.

xModify for Mootools

Mootools Home Page:
http://mootools.net/
xModify Extension:
xmodify-mootools.js (Uncompressed) (11 KB)
xmodify-mootools-compressed.js (Compressed) (4 KB)
xModify Usage:

						
 <script language="JavaScript" type="text/javascript" 
	src="javascript/jquery/mootools-latest.js"></script>
	
 <script language="JavaScript" type="text/javascript" 
	src="javascript/xmodify/xmodify-mootools.js"></script>
	

Call the xModify function from JavaScript, once called the xModify processor uses the XHR object to request the url and then process the response. You will need to typically send information to the server-side resource using a POST or GET. To do this append the parameters to the end of the url string, for example: 'login.jsp?username='+usernameValue+'password='+passwordValue};

							
var myXhr = new XHR({
                            async: true, 
                            method: "get",
                            onSuccess: function(){
                            }
                    });            
var result = myXhr.xmodify("statements/mootools/"+macroName+".xml");

Node Selectors:
The select attribute of the xModify operations is as defined on the following page.

Selectors Details

The operations will hand off the "select" attribute to the $(select-attribute-value).

HTML Blending:
    var selector = "#myDiv";
    var mode = "append"; //append, replace, replace-children, insert-before, insert-after
    var myXhr = new XHR(
                               {
                                   async: true, 
                                   method: "get",
                                   onSuccess: function(){
                                   }
                                }
                            );            
     var result = myXhr.blend("blend.html", selector, mode);
	

xModify for Prototype

Prototype Home Page:
http://www.prototypejs.org/
xModify Extension:
xmodify-prototype.js (Uncompressed) (11 KB)
xmodify-prototype-compressed.js (Compressed) (4 KB)
xModify Usage:

						
 <script language="JavaScript" type="text/javascript" 
	src="javascript/jquery/prototype-latest.js"></script>
	
 <script language="JavaScript" type="text/javascript" 
	src="javascript/xmodify/xmodify-prototype.js"></script>
	

Call the xModify function from JavaScript, once called the xModify processor uses the Ajax object to request the url and then process the response. You will need to typically send information to the server-side resource using a POST or GET. To do this append the parameters to the end of the url string, for example: 'login.jsp?username='+usernameValue+'password='+passwordValue};

							
	new Ajax.xmodify("statements/prototype/"+macroName+".xml");

Node Selectors:
The select attribute of the xModify operations is as defined on the following page.

Selectors Details

The operations will hand off the "select" attribute to the $(select-attribute-value).

HTML Blending:
    var selector = "#myDiv";
    var mode = "append"; //append, replace, replace-children, insert-before, insert-after
    new Ajax.blend("blend.html", selector, mode);