Validate HTML/RDFa in Python

南楼画角 提交于 2019-12-23 18:20:38

问题


What's the best way to go about writing a python module that can validate HTML, especially with embedded RDFa? I'm familiar with validator.w3.org, and I'm interested in writing a custom validator that performs a similar function, but for a different standard that utilizes RDFa for element metadata. What are some good pieces of source code to look at, Python libraries to try out, things to keep in mind?


回答1:


Emmett,

I am not sure what you want to achieve. I did write an RDFa distiller in Python. The first question you have to ask is whether you want to consider XHTML or HTML5. If the former, there are a bunch of XML environments around, and also DTD-s for RDFa usage. That could work. For HTML5, you may want to use the HTML5 parser in Python but that does not 'know' about RDFa, but it can produce, say, a DOM tree (or other representations) that you can then use to check the RDFa attributes. Note, however, that the HTML5 parser does not perform 'validation' in the sense of anaylizing the HTML5 code for various possible error conditions; it just produces a, say, DOM tree according to the HTML5 spec.

I hope this helps.

Cheers

Ivan



来源:https://stackoverflow.com/questions/11146520/validate-html-rdfa-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!