Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

AJAX - XSLT or JS?

 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have introduced AJAX into several of our existing and new web applications at the company I work for. In doing so, it almost seems as though we have fallen into two different schools of thought on the best practice for processing the returned XML on the browser side.

One side uses JavaScript to parse the XML, transform it into HTML markup, and insert it into the DOM. Their argument is maintainability, and many times the xml they are working with requires only the most rudimentary parsing for transformation.

The other group prefers using XSLT for the transformation, and only uses JS to work with the DOM object. Their argument is that XSLT is designed specifically for transforming XML, while javascript is designed more to work within the browser environment on a grander scale.

Since I work with the backend and build the service that returns the XML, it really doesn't matter to me... my XML looks the same regardless. Just watned to know other people's thoughts on the issue.
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have been using an Ajax-based front end to our product for about a year now and the biggest lesson I have learned is that you should really drop the X from Ajax... don't use XML as your data transport, use something lighter like JSON. As you add more and more actions to your application you add more and more XML processing and one of the slowest operations is building/serializing XML DOM. It has become our biggest front end performance hit.

I'd recommend using JSON as your data transport and treat it as a DTO on both ends, not the actual view. The backend creates the DTO and sends it to the front end. The front end converts it to JS (trivial with JSON) which can be used to manipulate the html to create the desired effects.

Hope this helps.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris.

We have actually begun looking into JSON, and are using it on one of our new projects. I am admittedly rather new to it, but it has intrigued me. Many times we already had web services set up to provide XML for legacy applications, so it made sense to reuse the existing functionality in our AJAX calls.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic