【发布时间】:2016-04-04 09:17:43
【问题描述】:
我正在尝试对具有两个不同名称空间的 XML (XHTML5) 进行查询,一个用于标签,一个用于属性。
这是一个例子:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<link href="primo.css" rel="stylesheet" type="text/css" />
<title>Incipit</title>
</head>
<body>
<p id="notauno" epub:type="footnote">Il nome della rosa è una cosa.</p>
</body>
</html>
所以,我有一个来自 epub 命名空间的“类型”属性。例如,我无法理解正确的 XQuery 语法来读取 p 标签(“脚注”)中 epub:type 的值。我尝试了不同的代码,如下所示:
xquery version "1.0";
declare namespace epub="http://www.idpf.org/2007/opf";
declare namespace h="http://www.w3.org/1999/xhtml";
let $sorgente:=fn:doc("file.xhtml")
for $nota in $sorgente//h:p
return data ($nota/@epub:type)
但是有一个我看不到的错误。如果有人可以帮助我,请提前致谢。
【问题讨论】:
-
"出现错误" -- 哪个错误?你得到什么输出,你提供的输入的预期输出是什么?
-
我的预期输出是“脚注”。我收到了“您的查询返回了一个空序列。”
-
你在使用 MarkLogic 吗?
-
我尝试使用 Oxygen 的 Saxon 和 BaseX 8.2.1
标签: xml html namespaces xquery epub