Code.Google.Com - AJAXSLT
The folks at Google have recently made available a number of new open source projects. These projects range from, general to specific, simple to complex, Google product/service related to no relation with any Google product or service. Additionally, these projects have all been used and developed inside the Googleplex and are being promoted by Google as part of an open source initiative. The code base is also expected to encourage software developers to create new applications that utilize Google’s technologies. Consequently, Google has also organized its API libraries under the code.google.com domain. The API libraries and open source code projects should provide you with more than enough source files to rummage through in your spare time.
Google has utilized its resources to develop an assortment of great services and they have spent additional time and money developing programming interfaces and open source software. The interfaces are simple but powerful and usually well documented, a combination that allows for cost effective implementations. Many businesses and individuals are using Google’s products and services but they have yet to realize Google as a service partner rather than just as a service provider. It is great to use Google’s AdWords to promote your company. There is an entirely different and greater benefit that is achieved by using the AdWords API in collaboration with AdWords.
Over the next few months I am going to be promoting some of these services that Google is offering. After reading through these posts I hope that you will develop enough familiarity with the tools to begin using them.
Currently, I am going to discuss an open source project named AJAXSLT. Google’s description of AJAXSLT is “An implementation of XSLT in JavaScript, intended for use in fat web pages, which are nowadays referred to as AJAX applications. Because XSLT uses XPath, it is also an implementation of XPath that can be used independently of XSLT.” I have compiled additional information regarding the project which you can access from googlefact.com. The project is a JavaScript implementation of XSLT that is abstracted to maximize cross browser compatibility.
I am going to be demonstrating the use of the XML parse functionality that is provided with this library. It can be implemented by including two files from the project: dom.js and misc.js. (note: you must include misc.js before dom.js) Additionally, I am going to use some of the AJAX functions from the primary JavaScript file used in Google’s Personalized home page. The functions outlined below are used to retrieve the xml data and to help assign the data to page elements. Click here to view the definitions of the functions listed below.
_esc(a) - to escape the parameters passed into the XMLHTTP query string
_gel(a) – to get an element by its ID
_trim(a) – to remove the spaces before and after a string
aP() – to get an XMLHTTP object used in the AJAX request
_sendx(a,aa) – to send an AJAX request to the server to get the xml data
The simple example retrieves an xml data set and populates a div tag from the data. The working example can be found here. You can also view the xml data document here. I intended to post the ViewNotes function, which is the main processing function in this example, but the WYSIWYG editor did not want to accept the syntax. Just take a moment to look over the source of the html document given in the link above.
Brief summary of the example code: The xml parse takes place in the _sendx function after we have retrieved the xml document from the server. We then loop through the elements in the xml object produced from the xmlParse function and assign them to a hash array that we can later refer to by name. That’s all there is to it. We have parsed and processed an AJAX request on the client side. Inspecting the working example should clear up any confusion that may have arisen from this post. Get all of the MSN Conspiracy Game Answers here
0 Comments:
Post a Comment
<< Home