I want to allow users to upload files with transaction information to my application. I want users to be able to user their own file format when doing so (XML or CSV).
So I’m going to need a transformation from their format to my format before doing further processing. I don’t want to have to create this XSLT manually every time a user has a new file format, so I want to create a UI to essentially build this XSLT document.
This is relatively easy for a CSV file format. The user says the first element maps to x field on my side, second element maps to 7 field etc.
This gets more complicated when the file format is XML with nested elements etc. Does anyone know of a good UI paradigm for doing so? Any examples I can look at on the web or elsewhere? I imagine the user would have to describe a full xpath as part of the mapping, or maybe first upload an XSD and use that to select elements for the mapping (after which I’d need to generate the XSLT).
I appreciate any ideas.
If the input XML can be mapped to your XML format in a straight-forward way, then a set of XPath expressions would be required from the user.
By “straight-forward way” I mean a very basic
<xsl:apply-templates>approach. The input XML must have individual records that can be addressed unambiguously, containing all the data in the right format. No data would require calculating or other special processing any more complex than what can be achieved by the evaluation of a single XPath expression.If the input is:
and your desired output would be:
then the user would have to provide the following mappings:
and the XSLT would be something like this (the values in “%” are to be replaced by the actual XPath expressions from the above mapping configuration):