已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
8中原工学院毕业设计(论文)译文专用纸Html和xhtml之间的不同从一开始,是超文本标记语言成就了万维网。它定义了我们在几乎每个网站上看到的页面,并同时传到了页面设计者的思想。像英语、法语、西班牙语、日语、俄语、或任何其他今天依旧被使用的语言一样,它是一个在变化和发展的“活”的语言。在早期,这种快速、突然的增长在万维网联盟中带来了“停滞”性质的功能。另外,许多设计师希望设计出渲染更快,结构更松散,内容量更大的网页。如果有些边角被剪掉?这里谈的关键是内容,内容才是最重要的。进入XHTML,我们可以尝试着通过一些努力,比如为支配万维网中web的发展而制造的一种xml的“方言”html。XHTML存在三种不同版本:过渡的,严格的,框架的,每个版本提供不同的功能以及对xml不同的符合度。对于单方面问题,也许html和xml之间最主要的区别就是XHTML必须被严格定义。你会说:这没什么大不了的。嗯,可能情况确实是这个样子。这个文档部分,就像脚被附加到额头那样,没有严格定义,却没有明显显现。因为一个XHTML文档实际上是XML,如果简单地遵循HTML,实践多年之后,我们就会陷入麻烦。考虑下下面两个HTML输入语句:两个html输入语句都是完全正确的html标签语句,但都由于没有严格定义,所以不符合xhtml标准。第一个语句的问题是,在HTML中,标签没有结束符是可以的,但同样的问题在xhtml中却是被禁止的。第二个语句的问题可能有点难辨识。我将给你一个提示:属性。是的,在XML,属性必须总是有值的,所以要给它一个值。disabled=disabled,看起来笨笨的,但它是能正确运行的。乍一看,似乎要求HTML 转换成XHTML,就是在HTML标记之前贴一个DTD,添加上缺少的结束符,清理掉没有赋值的属性。看呀,这就变成XHTML 了!好吧,也许,有时候,偶尔,除了星期二晚上或恰好一个满月,这是对的。你看,不幸的是,这仍然有潜在的问题。在我创建了第一个XHTML页面约5分钟后我无意中发现了这个问题,,那时的心情是,我感觉自己被出卖了。问题的根源来自,我在JavaScript函数中的比较。与五花八门的连接符(&)、大于号(),小于号()相比,文档没有被严格定义。我绝望了,我知道了Victor Frankenstein 的感受,被自己创造的事物绊倒。哦,这是多么讽刺呀!谢天谢地,我的绝望并没有持续很长时间。这并不像是有亲人去世,或 Stargate SG-1被取消掉,再或者任何这样重要的事情。它仅仅是人生道路的一个技术减速带(对于在宾夕法尼亚州的你来说,是一个白尾鹿)。XHTML实际上无非是XML的一种方言,同样,XSL和SVG也是。这意味着,尽管它属于规则的XML,但它也属于那些规则外的一些标准。例如,有两种方法可以确保一个“大于号”被严格定义,但是javascript不能处理>,实体也不是好的选择。这就只剩下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注释的目的,是从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 nearly 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 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 West 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 XHTML 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 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 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 always 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, occasionally, except on Tuesdays or at night during a full moon. You see, unfortunately, there is still a potential source of problems.I stumbled on this problem approximately 5 minutes after creating my first XHTML page, and I immediately felt betrayed. The source of the problem was compares 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. 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 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 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 parsed 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); els
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 加油站职业健康防护管理手册
- 设备科监管考核制度
- 办税服务厅考核制度
- 垃圾收运 考核制度
- 禽类养殖场考核制度
- 教代会畅谈考核制度
- 学校责任制考核制度
- 农村清洁工考核制度
- 紫金矿业考核制度
- 矿领导值班考核制度
- 2026年山东胜利职业学院单招综合素质考试题库附答案解析
- 不合格人员再培训制度
- 2025年采制样工岗位培训与考试题库采及答案
- 中国微生物肥项目创业投资方案
- 山东省潍坊市2025年中考数学真题附真题答案
- 137案例黑色三分钟生死一瞬间事故案例文字版
- 超声引导下外周静脉输液技术临床应用与进展
- 《骆驼祥子》知识点24章分章内容详述(按原著)
- 2024年救援车辆调度协议3篇
- 儿童镇静评估及护理
- 细胞治疗行业商业计划书
评论
0/150
提交评论