views:

53

answers:

3

We have an issue where we have an XML feed leaving our system and a client needs to be able to import this feed into their system but they require the XML file to be in a different format. For a number of reasons its not possible for either of us to alter our format. I was thinking then that it would make sense for us to build some kind of bridge, that imports our format and exports it in theirs. Obviously this is pretty simple when we know the formats in each position. What I would like to do though is build something more generic and less specific to that client so this bridge could be used by a number of people should they need it. What should I be looking at to achieve this? There are a number of methods I can think of such as template documents containing placeholder elements and some form of mapping data (in XML or in a DB) but it seems to me there should be a more elegant solution - maybe like the PHP XSL extension. We work predominantly in PHP so a PHP-based solution would be ideal but i'd be happy to consider anything that would work on a Linux box.

+2  A: 

Yes, XSLT is fairly effective at transforming one XML format to another, hence the "T". I've used it in the past with great success.

Ignacio Vazquez-Abrams
do you know of any good examples of this in action?
seengee
Nothing I can point you to, but they all work the same way: load the source, load the stylesheet, apply the stylesheet to the source, save the result.
Ignacio Vazquez-Abrams
+1  A: 

Indeed, XSLT is the way to go.

Some resources here: http://www.w3schools.com/xsl/default.asp

And the XSL extension for PHP is indeed an easy way to make it run.

Benoit Vidis
+3  A: 

As far as the "transforming" part of your question is concerned, yes, XSLT would be a reasonable approach.

But as far as the "could be used by a number of people should they need it" part of the question, don't try to build a generic system based on a single example. When you have three or four clients for which you're transforming your XML, then would be the time to find out what they all have in common.

Paul Clapham
I agree with the desire to build a generic map. If you try to build it now it will be wrong when other clients are on board because it will be impossible to predict their needs.
QSmienk