Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL to XML to XSLT to HTML, or SQL to HTML?

Tags:

html

sql

xml

xslt

Currently in the system I work on, we seem to convert our SQL result sets into XML, then use XSLT to generate the final HTML. In most cases we never actually use the XML other than via the XSLT to create valid HTML.

Today I found myself looking at our code, thinking to myself "Why not skip some steps and go straight from SQL results to HTML?" Is there (from your experience/knowledge) any reason why our current approach should ever be done? To me it just seems like more work/files to keep track of.

Also, does anyone know which approach is technically more correct, and why that approach is the correct one? Or is this just a matter of preference? I attempted searching around here and on Google, and I have yet to find a convincing reason one way or the other. Please help me out!

like image 827
JesseBuesking Avatar asked Oct 13 '22 17:10

JesseBuesking


1 Answers

Our system also uses Oracle XML+XSLT.

One scenario why this is good is when new requirements came. Our current reports must have the ability to be presented in CSV and Graph.

for CSV, its just a simple editing of the XSLT file without the need to change the structuring of SQL as XML. For the graph, all you need is to parse the XML, and that's it. we can also make our system a service which allows others systems to parse the xml to cater their needs.

Doing this approach indeed adds overhead to your system but gives you the ability to have an open-ended data representation. (i think, it's worth it)

like image 107
gianebao Avatar answered Nov 04 '22 00:11

gianebao