XHTML 1.0 Transitive,有没有可以重构HTML的工具?
我有一个使用以下配置设置运行的 Asp.net Web 应用程序。
<xhtmlConformance mode="Legacy"/>
这限制了 AJAX 的使用以及与多个浏览器的兼容性。
如果我的理解是正确的,则需要修复 aspx 页面的 HTML 代码以符合 XHTML 1.0 Transitional。
有很多 HTML 页面,大约 1000 个,有没有一个工具可以加快这个过程?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
DMS 软件重新工程工具包 是一个用于自动对大型源代码进行批量更改的工具基地。
DMS 使用语言精确的解析器来读取源代码,并使用语言精确的分析器来确定含义或问题。可以使用源到源程序转换来进行表单的更改, “如果您看到这个,请将其替换为那个”,用语言表面语法表示。这些模式由语言语法驱动,并应用于 DMS 解析器生成的 AST。
DMS 具有多种语言的语言前端,包括 HMTL 和 XHTML。
DMS 已用于“脏”HTML(即使有精确的定义!)来重构它。它可能非常适合解决您的修复 1000 页问题。
The DMS Software Reengineering Toolkit is a tool for automating mass change to large source code bases.
DMS uses language-precise parsers to read source code, and langauge-precise analyzers to determine meaning or problems. One can use Source to Source program transformations to carry out changes of the form, "if you see this, replace it by that" stated in terms of language surface syntax. The patterns are driven by the language grammar and are applied to ASTs generated by DMS parsers.
DMS has language front ends for a variety of languages, including HMTL and XHTML.
DMS has been used on "dirty" HTML (even that has a precise definition!) to refactor it. It might be a pretty good match for your fix-1000-pages problem.
当前页面是 HTML 还是 XHTML?如果它们是 HTML 格式,请保留它们。使用 XHTML 没有任何好处。
Are the pages currently in HTML or XHTML? If they are in HTML, leave them. There is no benefit to using XHTML.
HTML 5 支持使用 XML 语法,因此从旧版 HTML 迁移到 XHTML 将具有一些长期优势,因为您的页面在语法上将是正确的,这可以在完成后更轻松地迁移到 HTML 5 或 XHTML 2。
正如 大卫所述Dorward 在他的回答中,HTML Tidy 可能有用如果您有相当恒定的 HTML 标记,但考虑到页面数量,如果是这种情况,我会感到惊讶。如果您在 Google 上搜索“旧版 html 到 xhtml 工具" 其他一些可能值得研究的工具。
另一件需要考虑的事情是页面的编写方式。大多数旧版 HTML 页面在标记和样式之间没有明确的区分,因此您可能必须为 CSS 文件提取样式,而自动工具可能会遇到或错过这些样式。因此,您可能会遇到这样一种情况:最好的办法是坐下来访问网站并通过验证器(例如 W3C 标记验证服务或使用浏览器插件在您浏览网站时进行测试。 Firefox 的 Html Validator 非常好,通常就是这样我测试网络应用程序。这样做的缺点是,如果代码隐藏页面中生成了任何 HTML,您在测试期间可能不会遇到它。
HTML 5 supports the use of XML syntax so moving from legacy HTML to XHTML is going to have some long term advantages since you pages will be syntactically correct which could allow for an easier move to HTML 5 or XHTML 2 when they are completed.
As noted by David Dorward in his answer, HTML Tidy might be useful if you have fairly constant HTML markup, but given the number of pages I would be surprised if that was the case. If you do a Google search for "legacy html to xhtml tool" some other tools turnup that might be worth looking into.
Another thing to take into account is how the pages are written. Most legacy HTML pages don't have a clear separation between markup and styles so you are likely going to have to pull styling out for CSS files that automatic tools can be hit or miss with. As such, you might be looking at a situation where the best thing to do is sit down with the site and run the pages though a validator such as the W3C Markup Validation Service or use a browser plug-in to do the testing while you are browsing through the site. The Html Validator for Firefox is pretty good and this is generally how I test web applications. The downside to this that if there is any HTML that is being generated in the code-behind pages, you may not encounter it during testing.
Tidy 可能是最好的,但我从来没有对它完全满意,如果代码有那么糟糕吗?这通常表明它无论如何都需要重写。
Tidy is probably the best there is, but I've never been entirely happy with it, and if the code is that bad it is usually a sign that it needs rewriting anyway.