5

使用 HTML5 中的新文档类型和元素,您如何xdmp:tidy()在 HTML5 中识别它们?

如果我有一个包含以下内容的 html 页面:

<!DOCTYPE html>
<html>
    <header>blah</header>
    <section>blah</section>

然后尝试类似: xdmp:tidy(xdmp:document-get("home.html"))

我收到如下错误:

<section> is not recognized! discarding unexpected <section>
<header> is not recognized! discarding unexpected <header>

我可以发送一些选项xdmp:tidy()来让它处理它吗?

4

2 回答 2

1

本次讨论的其余部分移至位于http://markmail.org/thread/emwua43mg63wxbno的 marklogic 邮件列表


这确实会产生警告,但似乎仍然有效:

xquery 版本“1.0-ml”;

let $htmlstring :=
'<html>
    <header>blah</header>
    <section>blah</section>
<p>hello</p>
</html>'
return
xdmp:tidy($htmlstring,
<options xmlns="xdmp:tidy">
  <new-inline-tags>header section</new-inline-tags>
  <new-blocklevel-tags>header section</new-blocklevel-tags>
</options>)
于 2011-09-12T22:45:30.850 回答
1

尝试使用指定新 HTML5 标记的new-blocklevel-tags选项。您可以通过用逗号或空格分隔多个元素来包含多个元素。您应该得到没有错误的预期输出,但仍然会有警告。

在cq中试试这个:

xdmp:tidy(xdmp:document-get("home.html"), <options xmlns="xdmp:tidy"><new-blocklevel-tags>header section</new-blocklevel-tags></options>)

单击此处获取有关添加应作为 xdmp:tidy 中的选项的各种标记(块级、内联、空)的良好参考。相同的信息在这里,但有点难获得,有很多选择!

于 2011-09-02T23:31:02.383 回答