【发布时间】:2016-06-15 16:13:37
【问题描述】:
我想使用 XQuery(使用 Saxon XQuery 处理器)从 XML 数据生成 HTML 文件。
我正在尝试创建一个“干预者”(教师)列表,其中包含每个人所教的“单元”(课程)列表。
这是我的 XQuery 代码:
declare boundary-space preserve;
declare option saxon:output "method=xml";
declare option saxon:output "encoding=iso-8859-1";
declare option saxon:output "doctype-public=-//W3C//DTD XHTML 1.0 Strict//EN";
declare option saxon:output "doctype-system=-http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
declare function local:main() {
let $doc := doc("tp4.xml")/master
for $intervenant in $doc/intervenants/intervenant
order by $intervenant/nom
return local:displayIntervenant($intervenant)
};
declare function local:displayIntervenant($intervenant) {
<li>{data($intervenant/nom)} {data($intervenant/prénom)}</li>
<li>Unites: </li>
<ul>:here will be the function for getting "unites":</ul>
};
<html>
<body>
<h1>Intervenants</h1>
<ul>
{local:main()}
</ul>
</body>
</html>
我有以下错误:
$java -cp Saxon/saxon9he.jar net.sf.saxon.Query !indent=yes xq.txt > www/xq.html
Syntax error on line 19 at column 6 of file:/home/luc/Documents/XML/TP4/xq.txt near {...ant/prénom)}</li> <li>Unite...}
XPST0003: Left operand of '>' needs parentheses
第 19 行引用第二个 <li> 元素。
我不明白错误消息,我无法修复它。
【问题讨论】:
-
不是这里的问题,但我认为 HTML 不允许
<ul/>元素作为<ul/>元素的直接子元素。 -
你是对的!根据 html 的官方 dtd,
<ul/>不能是<ul/>元素的直接子元素。然而,大多数网络浏览器都能正确解释它们。再次感谢您