XLST was hailed at the end of the 90’s as being the uttimate tool to transform XML.
Theoretically you can use it to transform any XML into any other other format.
It can be very powerful (look at Code Generation).
However it needs to be treated especially carefully and be properly supported by unit tests of the transforms. Just because some clever code can be written does not mean that it should. Don’t take too many shortcuts.
Here is a useful python script that will make life a little easier:
import os
def XPathToXML(XPath):
s = XPath.split(“/”)
for x in s:
print (“<“+x+”>”
s.reverse()
for x in s:
print (“</”+x+”>”
if __name__ == “__main__”:
XPathToXML(os.argv[1])
This little beauty will take an XPath fragment such as
a/b/c and return:
<a>
<b>
<c>
</c>
</b>
</a>
Which is just what the doctor ordered when creating XSLT test data.