XHTML 1.1和浏览器兼容性 [英] XHTML 1.1 and browser compatibility

查看:67
本文介绍了XHTML 1.1和浏览器兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站现在使用Apache MultiViews和一些PHP代码来确定您的浏览器是否可以处理application / xhtml + xml媒体类型




如果它确实,该文件与该内容类型和XHTML 1.1

DOCTYPE一起发送。如果没有,它将以text / html和XHTML 1.0 DOCTYPE发送。


详细信息如何实现以及在途中解决的问题可以是

在这两页中可以看到:

http:// tranchant。 plus.com/notes/xhtml11
http:// tranchant .plus.com / notes / multiviews


我想知道的是,这是否会导致任何问题更多

使用选择不当的Accept标头隐藏浏览器。


请试试网站,如果它给你带来任何问题请告诉我。


谢谢!


-

Mark。
http://tranchant.plus.com/

解决方案

Mark Tranchant< ma ** @ tranchant .plus.com>写道:

我的网站现在使用Apache MultiViews和一些PHP代码来确定您的浏览器是否可以处理application / xhtml + xml媒体类型。

请试试网站,如果它给你带来任何问题,请告诉我。




Opera(7.5p3)获得1.0,搜索此群组以便早些时候讨论

关于如何做到这一点的内容协商。


-

Spartanicus


Mark Tranchant:

我的网站现在使用Apache MultiViews和一些PHP代码来确定您的浏览器是否可以处理application / xhtml + xml媒体类型。
如果是,则使用该内容类型和XHTML 1.1
DOCTYPE发送文档。如果没有,它将以text / html和XHTML 1.0 DOCTYPE发送。
在这两页中可以看到如何实现这一目标以及在途中解决的问题:
http://tranchant.plus.com/notes/xhtml11
http://tranchant.plus.com/notes/multiviews
我想知道的是,这是否会导致任何问题更糟糕的浏览器使用选择错误的Accept标题的问题。




因为您的PHP代码选择了内容类型可能会出现问题

太简单了。它只检查字符串

" application / xhtml + xml"的存在。在Accept标头中。这是一种非常普通的实际行动,但不正确。你必须至少检查q。价值

" text / html"和application / xhtml + xml,然后比较那些以查看

用户代理喜欢的内容类型。如果它优先选择

" text / html",那么它可能无法很好地处理XHTML 1.1。

如果你是感兴趣的我可以给你我自己的PHP代码。我不确定它是完美的,但它可能会好一些。


另一个问题是XHTMl 1.0版本你服务还没完成

完全根据HTML兼容性指南,当将XHTML 1.0作为text / html提供时应遵循
。实际上我在你的页面上只看到了一个这样的问题,在实践中它可能不是一个大问题,

但是因为看起来你正试图做的事情纠正到最后一个点,

你应该尝试纠正那个。这就是XHTML

1.0规范所说的:


C.7。 lang和xml:lang属性


在指定元素的语言

时,使用lang和xml:lang属性。 xml:lang属性的值优先。

xml:lang =" en"


< URL:http://www.w3 .org / TR / xhtml1 / #guideors>


您的网页可能还有其他类似的问题。


-

Bertilo Wennergren< be ****** @ gmx.net> < http://www.bertilow.com>


Bertilo Wennergren写道:

我的网站现在使用Apache MultiViews和一些PHP代码来确定您的浏览器是否可以处理application / xhtml + xml媒体类型。

如果是,则使用该内容发送文档类型和XHTML 1.1
DOCTYPE。如果没有,它将以text / html和XHTML 1.0 DOCTYPE发送。



由于选择内容类型的PHP代码可能会出现问题
太简单。它只检查字符串
application / xhtml + xml的存在。在Accept标头中。这是一种非常普遍的做法,但不正确。


是的,我知道。我需要更新那个页面,好像你读到了底部

你会看到一条说明我现在让Apache读取Accept标题

并选择哪一个两个文件服务。实际上,这两个文件是

相同,我的PHP代码使用所选的文件名来确定Apache选择哪一个



换句话说,我的PHP不会解析Accept标头。

另一个问题是你正在服务的XHTMl 1.0版本没有完全根据HTML兼容性完成在将XHTML 1.0作为text / html提供时应遵循的准则。实际上我在你的页面上只看到了一个这样的问题,在实践中它可能不是一个大问题,但是因为看起来你正试图把事情做到最后一点, 1.0规范所说的:

C.7。 lang和xml:lang属性

在指定元素的语言时使用lang和xml:lang属性。 xml:lang属性的值优先。
xml:lang =" en"




我知道那一个。我的问题是lang没有出现在XHTML

1.1中,所以我需要扩展我的文档修改以覆盖它。


I *相信*(虽然我愿意纠正)只是指定xml:lang

不违反XHTML 1.0规则?


感谢您指出这一点。也许我应该从定制的XML或XHTML 2.0开始切换到XSLT生成的

内容...


-

Mark。
http://tranchant.plus.com/


My site now uses Apache MultiViews and some PHP code to determine whether
your browser can handle the application/xhtml+xml media type.

If it does, the document is sent with that content type and the XHTML 1.1
DOCTYPE. If not, it is sent as text/html and the XHTML 1.0 DOCTYPE.

Details of how this is achieved and the problems solved en route can be
seen in these two pages:

http://tranchant.plus.com/notes/xhtml11
http://tranchant.plus.com/notes/multiviews

What I''d like to know, though, is whether this causes any problems for more
obscure browsers using badly-chosen Accept headers.

Please try the site and let me know if it gives you any problems.

Thanks!

--
Mark.
http://tranchant.plus.com/

解决方案

Mark Tranchant <ma**@tranchant.plus.com> wrote:

My site now uses Apache MultiViews and some PHP code to determine whether
your browser can handle the application/xhtml+xml media type.

Please try the site and let me know if it gives you any problems.



Opera (7.5p3) gets 1.0, search this group for earlier discussions on
content negotiation on how to do this proper.

--
Spartanicus


Mark Tranchant:

My site now uses Apache MultiViews and some PHP code to determine whether
your browser can handle the application/xhtml+xml media type. If it does, the document is sent with that content type and the XHTML 1.1
DOCTYPE. If not, it is sent as text/html and the XHTML 1.0 DOCTYPE. Details of how this is achieved and the problems solved en route can be
seen in these two pages: http://tranchant.plus.com/notes/xhtml11
http://tranchant.plus.com/notes/multiviews What I''d like to know, though, is whether this causes any problems for more
obscure browsers using badly-chosen Accept headers.



There can be problems since your PHP code that chooses the content type
is too simple. It only checks for the presence of the string
"application/xhtml+xml" in the Accept header. That''s a very common
practice, but not correct. You have to check at least the "q" values for
"text/html" and "application/xhtml+xml", and then compare those to see
which content type the user agent prefers. If it has a preference for
"text/html", then it might be that it can''t handle XHTML 1.1 very well.
If you''re interested I could give you my own PHP code. I''m not sure it''s
perfect, but it''s probably a bit better.

Another problem is that the XHTMl 1.0 version you''re serving is not done
entirely according to the HTML Compatibility Guidelines that should be
followed when serving XHTML 1.0 as "text/html". Actually I only saw one
such issue in your pages, and it might not be a big problem in practice,
but since it seems you''re trying to do things correct to the last dot,
you should probably try to correct that one too. Here''s what the XHTML
1.0 Specification says:

C.7. The lang and xml:lang Attributes

Use both the lang and xml:lang attributes when specifying the language
of an element. The value of the xml:lang attribute takes precedence.
xml:lang="en"

<URL:http://www.w3.org/TR/xhtml1/#guidelines>

There might be other similar issues in your pages.

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>


Bertilo Wennergren wrote:

My site now uses Apache MultiViews and some PHP code to determine whether
your browser can handle the application/xhtml+xml media type.

If it does, the document is sent with that content type and the XHTML 1.1
DOCTYPE. If not, it is sent as text/html and the XHTML 1.0 DOCTYPE.


There can be problems since your PHP code that chooses the content type
is too simple. It only checks for the presence of the string
"application/xhtml+xml" in the Accept header. That''s a very common
practice, but not correct.
Yeah, I know. I need to update that page, as if you read to the bottom
you''ll see a note explaining that I now let Apache read the Accept header
and choose which of two files to serve. In reality, these two files are the
same, and my PHP code uses the chosen filename to determine which one
Apache chose.

In other words, my PHP does not parse the Accept header.
Another problem is that the XHTMl 1.0 version you''re serving is not done
entirely according to the HTML Compatibility Guidelines that should be
followed when serving XHTML 1.0 as "text/html". Actually I only saw one
such issue in your pages, and it might not be a big problem in practice,
but since it seems you''re trying to do things correct to the last dot,
you should probably try to correct that one too. Here''s what the XHTML
1.0 Specification says:

C.7. The lang and xml:lang Attributes

Use both the lang and xml:lang attributes when specifying the language
of an element. The value of the xml:lang attribute takes precedence.
xml:lang="en"



I''m aware of that one. My problem is that lang does not appear in XHTML
1.1, so I''d need to extend my document modification to cover that too.

I *believe* (although I''m open to correction) that just specifying xml:lang
does not contravene XHTML 1.0 rules?

Thanks for pointing this out. Maybe I should switch to XSLT-generated
content, starting from bespoke XML or XHTML 2.0...

--
Mark.
http://tranchant.plus.com/


这篇关于XHTML 1.1和浏览器兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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