At work we have an ERP system that can receive information in a proprietary XML format via directory drop or Web service call.
Our customers place orders with us using disparate systems and methods. Fortunately most of them output some sort of XML.
How to convert one form of XML to another form of XML?
The answer is XML Stylesheet Language Translations or XSLT.
Basically you write a template in XSL and then apply it to an XML file and out pops a new XML/HTML file to your specifications.
I found that xsltproc (available in Cygwin and Linux) is a great test-bed tool.
When you are struggling to learn the XSL Language you don't need to add further complexity by trying to make it all work using VBS or JScript.
With the xsltproc tool you can write your XSL code and then try it out via the command line:
xsltproc yourstylesheet.xsl yourinput.xml
xsltproc by default sends your output to stdout which is great for debugging immediately...
XSLT allows you to massage the data and make decision as it parses the XML file so you can output the correct information.
I learnt enough to do a working XML to XML translation in about 2 days.
Once you have a working XSL file that converts the XML to the new format. The challenge is to script it.
Because we have Windows XP boxes I chose VBS and MSXML to apply the XSL to the XML and then do a webservice call to the remote ERP system. In Microsoft's attempt to provide some security for VBS scripts you find that trying to run a VBS from a network drive causes a security warning .... Grumble.
The things we learn.
Reference: http://www.w3schools.com/xsl/xsl_w3celementref.asp
0 Comments