SQL到XML到XSLT到HTML或SQL到HTML? [英] SQL to XML to XSLT to HTML, or SQL to HTML?

查看:119
本文介绍了SQL到XML到XSLT到HTML或SQL到HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前在我工作的系统中,我们似乎将我们的SQL结果集转换为XML,然后使用XSLT生成最终的HTML。在大多数情况下,除了通过XSLT创建有效的HTML之外,我们从未真正使用XML。

今天,我发现自己在看我们的代码,自言自语:为什么不跳过一些步骤,直接从SQL结果到HTML? (根据你的经验/知识)是否有任何理由为什么我们目前的方法应该完成?对我来说,它似乎是更多的工作/文件来跟踪。



另外,有谁知道哪种方法在技术上更加正确,为什么这种方法是正确的?或者这只是一个偏好问题?我试图在这里和谷歌上搜索,而我还没有找到一个有说服力的理由。请帮助我!

解决方案

我不相信有一个技术上更正确的版本。这归结于我们礼貌地称之为偏好的内容,但通常更偏向于偏见,他们在我的上一份工作中做了什么以及什么让经理感到安全。

另外,请记住第三个选项,将它们作为JSON传递给知道如何处理它们的智能JS客户端。有很多方法可以做到这一点。加上所有其他选项。



但无论如何,我自己更喜欢SQL结果 - > HTML,因为我觉得它更简单。 SQL结果以原生格式输出,并直接转到目标格式,不会产生维护令人头痛的中间步骤。

有些人会说,如果这是在代码中完成的它不是那么灵活,因为你必须改变代码,但是如果你看看改变XSLT所涉及的内容,并且正确地做到这一点,我宁愿乱用代码。



快速编辑:请记住,必须通过基本查询,转换为XML和XSLT来传播对查询的更改(例如新字段)最终布局的设计。如果你只是使用SQL-> HTML,你只需要改变查询和最后一步,不要再进行中间步骤。


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!

解决方案

I don't believe there is a "technically more correct" version. It comes down to what we politely call "preference" but is usually more like prejudice, what they did "at my last job" and what makes the manager feel safe.

Also, remember the third option, pass them as JSON to a smart JS client that knows what to do with them. There are plenty of ways to do it. Plus all the other options.

But anyway, I myself prefer the SQL results -> HTML because I find it simpler. The SQL results come in native format and go directly to the destination format, no in-between steps that produce maintenance headaches.

Some would say that if this is done in code it's not that flexible, because you have to change code, but if you look at what is involved in changing XSLT and getting it right, I'd prefer to mess with the code.

QUICK EDIT: Remember as well that a change to the query (such as new fields) must be propagated through the base query, the conversion to XML, and the XSLT, on top of changing the design of the final layout. If you just go SQL->HTML you just change the query and the final step, again, no in-between steps.

这篇关于SQL到XML到XSLT到HTML或SQL到HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆