请教:关于xsl/xslt的使用场合。

Magicloud 2003-09-02 08:47:25
什么情况用xsl/xslt加xml解析器,什么情况用程序代码(dom/sax)?
xsl/xslt是否有易编写,方便数据与程序分离的优势?
程序代码是否有功能强大,高效的优势?
两者的优势在什么场合下体现?
...全文
34 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jy_1201 2003-09-02
  • 打赏
  • 举报
回复
1、什么情况用XSL/XSLT加XM解析器
我想应该是转换输出新的XML文件吧
2、什么情况用程序代码(DOM/SAX)?

选择 DOM 还是 SAX,这取决于几个因素:

应用程序的目的:如果必须对数据进行更改,并且作为 XML 将它输出,则在大多数情况下,使用 DOM。与使用 XSL 转换来完成的简单结构更改不一样,如果是对数据本身进行更改,则尤其应该使用 DOM。
数据的数量:对于大文件,SAX 是更好的选择。
将如何使用数据:如果实际上只使用一小部分数据,则使用 SAX 将数据抽取到应用程序中,这种方法更好些。另一方面,如果知道将需要向后引用已经处理过的信息,则 SAX 可能不是正确的选择。
需要速度:通常,SAX 实现比 DOM 实现快。

------------------------
3、XSL/XSLT应访是方便数据和显示或输出格式的优势吧
4、??
5、??
saucer 2003-09-02
  • 打赏
  • 举报
回复
>>>什么情况用xsl/xslt加xml解析器,什么情况用程序代码(dom/sax)?

you probably mean the difference between using xsl/xslt stylesheet and using programming code to do transformation?

dom/sax are two major ways to parse/load an xml file

Dom is tree-based and memory intensive, easy to manipulate, suitable for small xml files

Sax is stream-based and lightweight, and good for extracting specific information or building your own data structure

you use XSL/XSLT to transform a dom into xml or other format. Current getneration of xsl/xslt processors are DOM-based


>>>>xsl/xslt是否有易编写

易编写? no

>>>方便数据与程序分离的优势?

yes, but it is a transformation language, you shouldn't embed too much presentation in an stylesheet, you should use templated xml file for presentation

>>>>>程序代码是否有功能强大,高效的优势?

sure, but it is inflexible, since you have to write code to do node manipulation, also sometimes your code becomes very complicated. If you need to make changes, you need to recompile your code. With XSLT, you can modify them and use it right away

>>>>两者的优势在什么场合下体现?

code: your transformation is fixed and requires high performance.

stylesheet: all other situations, it is possible (in Java) to pre-compile XSLT stylesheet into code to improve performance

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧