My PHP app needs to export to a range of different XML formats: should I use XSLT or native PHP? -
My PHP application should be able to export in different data formats (and by importing), mostly XML based .
I have the option
- In PHP, use the DOM to export some XML based format which is a superset of all the data needed for others, Create more to run the DOM output via PHP's XSL extension, a different XSLT stylesheet for each output format. I am running the DOM output via PHP's XSL extension.
or
- But implementing each output format as a class of every generation that is directly using the DOM from internal objects / structures Translates into given XML format, each such class implements the same interface so that they are interchangeable.
The app will be used by universities and it is a tool that manages people's records in various ways, and imports / exports from various sources such as their HR system , e.t.c. I am implementing these input and output formats elf, but in the future there is such a chance that someone who uses it would like to modify it to support its format.
One reason I'm not considering using XSLT is that if someone else in the future, except me, it seems that very few people also know XSLT - too many people are using PHP Find out
The second is that the second seems like a more efficient and 'programmer' solution, and is more flexible in the sense that I should be able to produce and from non-XML formats such as CSV or column based text It can not be imported by overloading the necessary parts of the class, it is not necessary that it is often necessary.
One third, but a very small and unimportant reason is that PHP requires XSL to be enabled, while DOM is enabled by default, so it will be a little more portable.
Probably can be used for two-way solution You can create an adapter system for exporting and exporting XSLT for XML data formats and using PHP code for all data formats not being XML-based. Can provide the ability of. Thus every developer can choose the way he likes.
Interface My_DataConverter_Interface {/ ** * @ Ultimate String $ file * @Return My_DataObject * / function import ($ file); / ** * @ Param My_DataObject $ data * @ Ultimate String $ file * / Function Export (My_DataObject $ data, $ file); } Intangible class My_DataConverter_Xslt implies My_DataConverter_Interface {/ * ... * /} class My_DataConverter_XmlFormat1 Expands My_DataConverter_Xslt {/ * ... * /} class My_DataConverter_XmlFormat2 Expands My_DataConverter_Xslt {/ * ... * /} class My_DataConverter_Csv My_DataConverter_Interface Applies {/ * ... * /}
Comments
Post a Comment