《Html和xhtml之间的不同毕业设计(论文)外文译文.doc》由会员分享,可在线阅读,更多相关《Html和xhtml之间的不同毕业设计(论文)外文译文.doc(8页珍藏版)》请在三一办公上搜索。
1、Html和xhtml之间的不同从一开始,是超文本标记语言成就了万维网。它定义了我们在几乎每个网站上看到的页面,并同时传到了页面设计者的思想。像英语、法语、西班牙语、日语、俄语、或任何其他今天依旧被使用的语言一样,它是一个在变化和发展的“活”的语言。在早期,这种快速、突然的增长在万维网联盟中带来了“停滞”性质的功能。另外,许多设计师希望设计出渲染更快,结构更松散,内容量更大的网页。如果有些边角被剪掉?这里谈的关键是内容,内容才是最重要的。进入XHTML,我们可以尝试着通过一些努力,比如为支配万维网中web的发展而制造的一种xml的“方言”html。XHTML存在三种不同版本:过渡的,严格的,框架
2、的,每个版本提供不同的功能以及对xml不同的符合度。对于单方面问题,也许html和xml之间最主要的区别就是XHTML必须被严格定义。你会说:这没什么大不了的。嗯,可能情况确实是这个样子。这个文档部分,就像脚被附加到额头那样,没有严格定义,却没有明显显现。因为一个XHTML文档实际上是XML,如果简单地遵循HTML,实践多年之后,我们就会陷入麻烦。考虑下下面两个HTML输入语句:两个html输入语句都是完全正确的html标签语句,但都由于没有严格定义,所以不符合xhtml标准。第一个语句的问题是,在HTML中,标签没有结束符是可以的,但同样的问题在xhtml中却是被禁止的。第二个语句的问题可能
3、有点难辨识。我将给你一个提示:属性。是的,在XML,属性必须总是有值的,所以要给它一个值。disabled=disabled,看起来笨笨的,但它是能正确运行的。乍一看,似乎要求HTML 转换成XHTML,就是在HTML标记之前贴一个DTD,添加上缺少的结束符,清理掉没有赋值的属性。看呀,这就变成XHTML 了!好吧,也许,有时候,偶尔,除了星期二晚上或恰好一个满月,这是对的。你看,不幸的是,这仍然有潜在的问题。在我创建了第一个XHTML页面约5分钟后我无意中发现了这个问题,,那时的心情是,我感觉自己被出卖了。问题的根源来自,我在JavaScript函数中的比较。与五花八门的连接符(&)、大于号
4、(),小于号()相比,文档没有被严格定义。我绝望了,我知道了Victor Frankenstein 的感受,被自己创造的事物绊倒。哦,这是多么讽刺呀!谢天谢地,我的绝望并没有持续很长时间。这并不像是有亲人去世,或 Stargate SG-1被取消掉,再或者任何这样重要的事情。它仅仅是人生道路的一个技术减速带(对于在宾夕法尼亚州的你来说,是一个白尾鹿)。XHTML实际上无非是XML的一种方言,同样,XSL和SVG也是。这意味着,尽管它属于规则的XML,但它也属于那些规则外的一些标准。例如,有两种方法可以确保一个“大于号”被严格定义,但是javascript不能处理>,实体也不是好的选择。这
5、就只剩下CDATA来从浏览器端隐藏掉javascript了。如果你不熟悉CDATA,它对于XML相当于说“不要注意被帘子隐藏的事物”。基本上,任何在CDATA中的内容都不会被解析为XML,对于上面的情况,这再方便不过了。不过,还有一个问题,使用CDATA,某些web浏览器出现兼容性问题,所以有必要把它以Listing 3-1中的方式隐藏掉。Listing 3-1,隐藏CDATA !- b) alert(a is bigger); else if(a = b) alert(a & b are equal); else alert(b is bigger)/ -HTML / XML注释的目的,是从
6、HTML中隐藏掉CDATA中的内容。JavaScript的注释可以防止选择浏览器从而避开有问题的JavaScript透视图。虽然他可能看清来并不美观,但是起到的作用很好。 The Difference Between HTML and XHTMLFrom its very beginning, Hypertext Markup Language is what has made the World Wide Web possible. It both conveys the thoughts of the person who created the page and defines near
7、ly every aspect of what we see on each and every web page visited. Like English, French, Spanish, Japanese, Russian, or any other language in use today, it is a living language, evolving and growing.Early on, this growth was fast and sudden, with features often doing an end-run around the World Wide
8、 Web Consortium. Add to that the fact that many of the designers of web pages play fast and loose in an effort to have more content than the next guy. So what if some corners were cut? It was all about content, and content was king.Enter XHTML, considered by some as an effort to reign in the Wild We
9、st approach to web development by making HTML a dialect of XML. XHTML came in three flavors: transitional, strict, and frameset, with each flavor offering either different capabilities or different degrees of conformance to the XML standard.Probably the biggest single difference between HTML and XHT
10、ML is that XHTML must be well formed. Not a big deal, you say. Well, it could be. The part of the document that isnt well formed doesnt have to be glaring, like a foot being attached to the forehead. Because an XHTML document is essentially XML, simply following the HTML practices that weve followed
11、 for years is enough to get us into trouble. Consider the following two HTML input statements:Both statements are perfectly acceptable HTML, but as XHTML, they dont make the grade because neither is well formed. The problem with the first statement is that the tag isnt closedperfectly acceptable in
12、HTML, but verboten in XHTML. Fortunately, correcting it is a simple matter; just close the tag in the manner of self-closing tags or treat it as a container tag. The problem with the second statement might be a little harder to spot. Ill give you a hint: attributes. Yes, in XML, attributes must alwa
13、ys have values, so give it one. disabled=disabled might look goofy, but it works.At first glance, it might appear that all that is required to convert HTML into XHTML is to slap a DTD before the HTML tag, close some tags, and clean up some attributes. Voil, instant XHTML! Well, maybe, sometimes, occ
14、asionally, except on Tuesdays or at night during a full moon. You see, unfortunately, there is still a potential source of problems.待添加的隐藏文字内容3I stumbled on this problem approximately 5 minutes after creating my first XHTML page, and I immediately felt betrayed. The source of the problem was compare
15、s in my JavaScript functions. With the assorted compares using ampersand (&), greater than (), and less than (), the document wasnt well formed. In my despair, I knew how Victor Frankenstein felt, brought down by creatures of my own creation. Oh, the irony!Thankfully, my despair didnt last very long
16、. It wasnt like there was a death in the family, or Stargate SG-1 had been cancelled, or anything important like that. It was merely a technical speed bump (or white tail deer, to those of you in Pennsylvania) on the road of life. I wasnt worried because I knew a trick that would make anything well
17、formed.XHTML is really nothing more than a dialect of XML, in the same way that both XSL and SVG are. This means that although it falls under the rules of XML, it also falls under the exceptions to those rules. For example, there are two ways to ensure that a greater than is well formed, but because
18、 JavaScript cant handle > entities arent an option. This leaves only CDATA as the way to hide the JavaScript from the browser.If youre unfamiliar with CDATA, it is the XML equivalent of saying Pay no attention to that man behind the curtain. Basically, anything that is within the CDATA wont be pa
19、rsed as XML, which is quite convenient for this case. There is, however, one problem with using CDATA; certain web browsers have issues with it, so it is necessary to hide it from the browser in the manner shown in Listing 3-1.Listing 3-1. Hiding CDATA !- b) alert(a is bigger); else if(a = b) alert(a & b are equal); else alert(b is bigger)/ -The purpose of the HTML/XML comments is to hide the CDATA section from HTML. The JavaScript comment prevents select browsers from having issues from a JavaScript perspective. Although it might not be pretty to look at, it does work well.