- use xslt to transform directly into xhtml -> serialize to xhtml -> render page
One use case was where I needed to transform a large xml document describing some tree like structure and the customer wanted that tree to be displayed nicely as a tree.
I'd like to describe how you can generically convert any xml document into json.
Let's first start taking a quick look at what JSON is all about.
You basically have to deal with arrays, objects, dates, booleans, numbers and strings.
Based on the above we can come up with a generic XML way of describing the above:
So we can easily write a generic transformer for this use case:
Now you only need to convert your input xml file into the generic JSON xml structure and transform it with the above stylesheet.