I have a lot of information distributed among some tables in a database (and must likely it will all be represented into oop). I will need to create text files with different formats from the same data depending on the request. My idea is to开发者_StackOverflow社区 create a design that will require no coding if such formats are to change of be added.
I was thinking in using some sort of XML magic trick to accomplish this but I have no idea how to. I am also open to new ideas.
There are no magic tricks ;)
If you create XML schemas for your database objects, you could render them as XML. Then you could use appropriate XML transforms to, well, transform the XML to the requested formats. Read up on XSLT. This would still require you to maintain XSLT style sheets for each different type of transformation (say, XML to HTML, XML to CSV...)
You aren't too clear about the different target formats or the intended uses of your system. If the formats are simple and differ only in columns displayed or the order they are displayed in, you could create an interface that allows the user to customize the resultant format. Alternatively, you could create a templating language.
精彩评论