本文介绍了是否使用"JSP文档"? /"XML表示法中的JSP"暗示输出XHTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我真的不确定:使用"JSP文档"/"XML表示法的JSP"是否意味着输出XHTML?

I'm really not sure about this: does using "JSP Document" / "JSP in XML notation" imply outputting XHTML?

如果是这样,那么生成一个有效的" XHTML页面是否有什么特别的照顾?

If so, is there anything special to look after as to produce a "valid" XHTML page?

更具体地说:我可以使用有效的"JSP文档"(XML中的JSP)来生成无效的XHTML页面吗?

More specifically: can I have a valid "JSP Document" (JSP in XML) that is producing an invalid XHTML page?

推荐答案

这至少意味着使用和生成格式良好的XML.如果编写无效的XML,则在解析过程中将出错.如果它生成格式正确的XML,则它不可能是HTML4,因为不允许关闭诸如brhrmetalink之类的短标记.

It at least implies consuming and producing well formed XML. If you write invalid XML, then it will error during parsing. If it produces well formed XML, then it can impossibly be HTML4 because closing shorttags like br, hr, meta and link is disallowed.

由于XML的格式正确,因此您应该选择XHTML或HTML5.当HTML5规范仍处于草稿模式时,它允许关闭短标签.另请参见第3.2.2章元素的结尾:

Since it's well formed XML, you should choose either XHTML or HTML5. While HTML5 specification is still in draft mode, it allows closing shorttags. Also see the end of chapter 3.2.2 Elements:

HTML示例:

<link type="text/css" rel="stylesheet" href="style.css">

在XHTML中,XML语法要求规定必须使用上述的显式结束标记或空元素语法将其显式显示.这是通过在开始标记的结尾处,在直角括号之前的位置插入一个斜线来实现的.

In XHTML, the XML syntactic requirements dictate that this must be made explicit using either an explicit end tag, as above, or the empty element syntax. This is achieved by inserting a slash at the end of the start tag immediately before the right angle bracket.

示例:

<link type="text/css" href="style.css"/>

作者还可以选择对HTML语法中的void元素使用相同的语法.一些作者还选择在斜杠之前包含空格,但这不是必需的. (以这种方式使用空格是从XHTML 1.0附录C中的兼容性准则继承的约定.)

Authors may optionally choose to use this same syntax for void elements in the HTML syntax as well. Some authors also choose to include whitespace before the slash, however this is not necessary. (Using whitespace in that fashion is a convention inherited from the compatibility guidelines in XHTML 1.0, Appendix C.)


然后,在过渡和严格之间进行选择取决于您要支持的Web标准的程度.为此,底部的表格 .iki.fi/doctype/"rel =" nofollow noreferrer>此网站提供了出色的概述.


Then, the choice between transitional and strict depends on the degree of web standards you'd like to support. For that, the table at the bottom of this website gives an excellent overview.

首先,您要避免使用 Quirks Mode 尽可能多,因为这会触发MSIE浏览器中的框模型错误由CSS指定时,元素的边距,内边距和尺寸不适当.缺少文档类型或不正确的文档类型将触发此模式.

To start, you'd like to avoid the Quirks Mode as much as possible since that triggers the box model bug in MSIE browser which causes inconsitenties in margins, paddings, dimensions of the elements when specified by CSS. The lack of the doctype or an incorrect doctype will trigger this mode.

我强烈建议选择一个 Strict 文档类型,因为这样盒子模型和行为在世界范围内意识到的不同网络浏览器中将尽可能保持一致.以下两种文档类型都可以,取决于您要支持/确认的元素/属性.

I strongly recommend to pick a Strict doctype since the box model and behaviour would then be as much as possible consistent among the different webbrowsers the world is aware of. Either of the following doctypes is okay, depending on what elements/attributes you'd like to support/vaildate.

严格的XHTML 1.0 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

或更新的 XHTML 1.1(严格的,基于模块的):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

或(仍处于草稿模式) HTML5文档类型:

or the (still in draft mode) HTML5 doctype:

<!DOCTYPE html>

请注意,在使用XHTML时,需要确保将HTTP Content-Type标头设置为text/html,而不是application/xmlapplication/xhtml+xml,否则MSIE可能仍会发疯,因为它不支持该功能.另请参见上述doctype网站,以获取更多详细信息.同一篇文章确实提到将 XHTML用作text/html被认为是有害的,但这仅在它适用时适用使用<?xml?>声明呈现和/或包含未嵌入在CDATA块中的内联JavaScript.

Note that you need to ensure that the HTTP Content-Type header is set to text/html, not application/xml nor application/xhtml+xml when going for XHTML, else MSIE may still go mad since it doesn't support that. Also see the aforementioned doctype website for more detail. The same article indeed mentions that serving XHTML as text/html is considered harmful, but that only applies when it get rendered with the <?xml?> declaration and/or contains inline JavaScripts not embedded in CDATA blocks.

这篇关于是否使用"JSP文档"? /"XML表示法中的JSP"暗示输出XHTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:34