拥有一个带有两个 XML 标签的网站有什么好处? [英] What's the advantage of having a website with two XML tags?

查看:24
本文介绍了拥有一个带有两个 XML 标签的网站有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在星际争霸 2 网站上结束并决定看一看他们的来源并看到了这个:

I was over at the StarCraft2 website and decided to take a look at their source and saw this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="layout/artwork.xsl"?>

<page lang="en_us">
  <artwork/>
</page>

……就是这样.所以我想知道,如果您只使用 2 个标签,那么使用 XSLT 有什么意义?是为了混淆源吗?

... and that's it. So I was wondering, what's the point in using an XSLT if you're just using 2 tags? Is it to obfuscate the source?

我只是想澄清一下,我不是在问 XSLT 是如何工作的.我问以这种方式设置页面有什么好处.在我看来,XSLT 使用不当.

I just want to clarify that I'm not asking how XSLTs work. I asking what is the advantage of setting up a page in this manner. It seems to me like a poor use of XSLTs.

推荐答案

需要注意的一点是,每个页面元素都有一个 lang 属性,该属性根据浏览器提供的 Accept-Language http 标头进行修改.XSLT 使用此属性来选择本地化资源.该模板的组织方式也使得许多常见的页面元素(如标题和 Flash 对象)都定义在一个常见的includes.xsl"文件中.

Well one thing to notice is that each page element has a lang attribute that is modified based on the Accept-Language http header provided by the browser. The XSLT uses this attribute to select localized resources. The template is also organized in such a way that many common page elements, like headers and flash objects, are defined in a common "includes.xsl" file.

由于所有的本地化和 html 渲染都是由客户端完成的,这可能会节省大量的服务器 CPU 时间.此外,鉴于许多元素定义在全局包含"文件中,浏览器可以请求一次并缓存,从而节省带宽并减少下载每个页面的总时间.

Since all of the localization and html rendering is done by the client, this probably saves a fair amount of server CPU time. Also, given that many elements are defined in a global "includes" file, this can be requested once by the browser and cached, saving bandwidth and reducing the overall time to download each page.

这篇关于拥有一个带有两个 XML 标签的网站有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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