Converting XML to JSON with XSL – Part 3

In this final installment of converting XML to JSON with XSL I will move outside of the ‘normal’ JSON conventions in order to provide data typing of returned values as well as flattening your resulting JSON for greater efficiency. Although naming conventions like BadgerFish provide for backwards conversion to XML it is often the case that this is not required.  Conventions like BadgerFish also make the assumption that the source of the JSON may ‘not’ be safe and therefore all entities and corresponding values are encased as strings. Continue reading


Converting XML to JSON with XSL – Part 2

In this installment of converting XML to JSON with XSL I will discuss escaping your resulting JSON plus the introduction of a config.xml file to drive your conversion.  The config file becomes a necessity in order to do datatyping and character escaping.  Continue reading

Faster than google can catch up

In my previous post on converting XML to JSON with XSL I mentioned that no one seemed to have done it. Well I made my initial search at the beginning of the year. Now when I search someone posted how to do it on there blog on January 21. Now I have to go through that implementation and see if it goes beyond my finished piece or has some nice ideas to add in.

Amazing how two people 6000 miles appart start working on the same thing at the same time. Believe there is a word for that but it fails me at the moment.

You can check out the implemenation at


Converting XML to JSON with XSL – Part 1

A little while ago I was doing some playing around with Extjs and I found that the majority of the Ajax calls where expecting JSON back rather than XML. At this point I thought to myself ‘right then someone must have a converter out there in pure XSL. To my great surprise no one seems to either written one or made it public. So, based on this finding I think this will make an excellent, if long, first blog post.

The core idea for the converter is to use only the basic functionality provided in XSL. This means no library/namespace extensions. This will provide for the transformer to be portable across all major web platforms, such as JAVA, PHP, CFM and of course .NET.

For the purpose of this post I will use a simple XML file with some basic content as the example. I will lay out the creation of the transformer as I wrote it. I will use the JSON Badgerfish convention and later in the post show how to deviate from it and why. At the end of the post I will cover the introduction of a config.xml file to drive the transformations. The actual server side transformation will be covered lastly and will be in VB.NET and C#. Continue reading