Friday, April 27, 2007

Never Mind the Namespaces: An E4X client

Bob DuCharme published "Never Mind the Namespaces: An XSLT RSS Client" way back in January 2003. It is one of my favourite articles and I have regularly returned to it over the years.

Essentially it demonstrates how the XPath local-name() function can be used to create a single universal XSLT stylesheet that would work with the many RSS formats that share a similar construction but different namespace. As far as the typical XML processor is concerned a difference in namespace is usually an extremely significant difference and using local-name() function essentially gives you the power to write XSLT thats says "I do not care what namespace the 'item' element is in just give it to me".

I have started using E4X in real projects recently and it also supports functionality equivalent to the XPath local-name() function. Ignoring how data is loaded into the DOM, the following are pretty much equivalents.





This ability means we can write an E4X script that can also render RSS/Atom paying little heed to namespaces.

The following example is probably not perfect but in theoretically it could load any RSS/Atom and render it. Additional action would be necessary to bypass XMLHttpRequest security constraints for accessing remote feeds.

Assuming you have a decent browser that supports E4X the following should work (e.g. Firefox 2).


madin said...

replica louboutin italyFondato nel 1993, repliche donne appartamentigli iconici tacchi a suola rossa di Christian Louboutin sono ancora i tacchi più alla moda nel mondo della moda. Le impareggiabili vendite di Christian Louboutin rendono la tua collezione di scarpe ancora più equilibrata, in cui troverai allettanti tacchi Louboutin e scarpe Louboutin uniche delle dimensioni perfette.

madin said...

Alexander McQueen is an iconic replica ALEXANDER MCQUEEN Shoes fashion house creatively cheap ALEXANDER MCQUEEN sneaker womens taken over by Sarah Burton who continues to work and evolve with the brand, offering a luxurious range of prêt-à-porter clothing and accessories.

madin said...

Paris Fashion Week would Replica handbags uk have been incomplete without replica Yves Saint Laurent bags Anthony Vaccarello’s homage to maison founder Yves Saint Laurent in the Saint Laurent spring/summer 2019 collection.

madin said...

Longines watches have been a landmark of the industry since their brand began best replica watches in 1832 in Saint-Imier. Today, the brand offers a wide variety of watches for men and women. Watches manufactured by Longines have been utilized throughout history for replica Longines Elegant watches everything from exploration ventures to the expression of elegance. In addition to being famous for their ties to the racing and equestrian worlds, Longines watches are globally recognized for their timeless chic sophistication. we have a variety of Longines watches for sale, all new, beautiful, and guaranteed to be genuine. Even better, when shopping our Longines watches online, you know you are getting the best value. Browse our selection to find the Internet’s best Longines watch price.