XHTML 验证、自定义名称空间和属性 [英] XHTML validation, custom namespaces and attributes

查看:22
本文介绍了XHTML 验证、自定义名称空间和属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户要求 XHTML 有效的网站.他们使用 W3C 验证器对其进行检查.

I have a website that a client requires to be XHTML valid. They check it using the W3C validator.

我想添加我自己的命名空间和属性,这样我就可以做这样的事情:

I want to add my own namespace and attributes so I can do things like this:

<div my:userid="123"> ... </div>

据我了解,定义自定义命名空间是完全有效的 XHTML,只要我这样做:

From what I understand, defining custom namespaces is perfectly valid XHTML, as long as I do this:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:my="http://www.example.com/my">

但是,我的 XHTML 验证失败.问题似乎是验证器实际上并没有出去检查我的自定义 DTD 文档是否有我的自定义命名空间,它只检查 XHTML 与已知的 DTD.任何人都可以阐明我如何解决这个问题?

However, my XHTML fails validation. The problem appears to be that the validator does not actually go out and check my custom DTD document for my custom namespace, it only checks the XHTML against known DTD's. Anyone able to shed any light on how I can solve this problem?

推荐答案

对于 XHTML 1.0,您只能使用 XHTML 1.0 元素和属性:

For XHTML 1.0 you are restricted to XHTML 1.0 elements and attributes:

XHTML 1.0 的规范定义

此版本的 XHTML 提供了严格符合 XHTML 1.0 文档的定义,这些文档仅限于来自 XML 和 XHTML 1.0 命名空间的元素和属性.

This version of XHTML provides a definition of strictly conforming XHTML 1.0 documents, which are restricted to elements and attributes from the XML and XHTML 1.0 namespaces.

我的理解是 XHTML 2.0 旨在提供一个框架来做你想做的事.

My understanding is that XHTML 2.0 aims at providing a framework for doing what you want.

这篇关于XHTML 验证、自定义名称空间和属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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