Xquery 为什么我会得到一个;意外标记“;返回opf文件(ePub)的元标记时出错?

Xquery 为什么我会得到一个;意外标记“;返回opf文件(ePub)的元标记时出错?,xquery,exist-db,Xquery,Exist Db,我仍在为ePub制作构建我的应用程序。目前,我能够为更多作者生成记录,但无法解决一个奇怪的错误 我的代码: { for $i in (1 to 20) let $authRequestGivenName := 'authorGivenName' || $i let $authRequestSurname := 'authorSurname' || $i let $authorGivenName := request:get-parameter($authReque

我仍在为ePub制作构建我的应用程序。目前,我能够为更多作者生成记录,但无法解决一个奇怪的错误

我的代码:

{
    for $i in (1 to 20)
    let $authRequestGivenName := 'authorGivenName' || $i
    let $authRequestSurname := 'authorSurname' || $i
    let $authorGivenName := request:get-parameter($authRequestGivenName, '')
    let $authorSurname := request:get-parameter($authRequestSurname, '')
    return
        if ($authorGivenName)
        then
            <dc:creator id="author{$i}">{$authorGivenName || ' ' || $authorSurname}</dc:creator>
                <meta refines="#author{$i}" property="file-as">{$authorSurname || ', ' $authorGivenName}</meta>
                <meta refines="#author{$i}" property="role" scheme="marc:relators">aut</meta>
                <meta refines="#author{$i}" property="role" scheme="onix:codelist17">A01</meta>
        else ()
}

…如
refines
是它的一些特殊关键字。

这是一个语法错误。如果要在一个位置返回一个元素序列(多个元素),则必须将它们包装成序列
(,)
,而不是只列出它们
。同样,在
元素之后,已经需要
else
语句

按顺序包装元素,注意分隔元素的逗号

if ($authorGivenName)
then (
    <dc:creator id="author{$i}">{$authorGivenName || ' ' || $authorSurname}</dc:creator>,
    <meta refines="#author{$i}" property="file-as">{$authorSurname || ', ' $authorGivenName}</meta>,
    <meta refines="#author{$i}" property="role" scheme="marc:relators">aut</meta>,
    <meta refines="#author{$i}" property="role" scheme="onix:codelist17">A01</meta>
)
else ()
if($authorGivenName)
然后(
{$authorGivenName | |''.| |$authorSurname},
{$authorSurname | |','$authorGivenName},
aut,
A01
)
else()
同时,这个缩进让我感到困惑。是否确实要将
元素创建为
的子元素?如果是这样,在
元素之后移动结束标记也可以解决问题,因为您只返回一个XML元素(哪些子节点)

if($authorGivenName)
然后
{$authorGivenName | |'.| |$authorUrName}
{$authorSurname | |','$authorGivenName},
aut,
A01
else()

这是一个语法错误。如果要在一个位置返回一个元素序列(多个元素),则必须将它们包装成序列
(,)
,而不是只列出它们
。同样,在
元素之后,已经需要
else
语句

按顺序包装元素,注意分隔元素的逗号

if ($authorGivenName)
then (
    <dc:creator id="author{$i}">{$authorGivenName || ' ' || $authorSurname}</dc:creator>,
    <meta refines="#author{$i}" property="file-as">{$authorSurname || ', ' $authorGivenName}</meta>,
    <meta refines="#author{$i}" property="role" scheme="marc:relators">aut</meta>,
    <meta refines="#author{$i}" property="role" scheme="onix:codelist17">A01</meta>
)
else ()
if($authorGivenName)
然后(
{$authorGivenName | |''.| |$authorSurname},
{$authorSurname | |','$authorGivenName},
aut,
A01
)
else()
同时,这个缩进让我感到困惑。是否确实要将
元素创建为
的子元素?如果是这样,在
元素之后移动结束标记也可以解决问题,因为您只返回一个XML元素(哪些子节点)

if($authorGivenName)
然后
{$authorGivenName | |'.| |$authorUrName}
{$authorSurname | |','$authorGivenName},
aut,
A01
else()

非常感谢,你说得对!至于缩进,这只是手动ePub编码的一个坏习惯(当然,元细化不是dc:creator元素的子元素)。谢谢非常感谢,你说得对!至于缩进,这只是手动ePub编码的一个坏习惯(当然,元细化不是dc:creator元素的子元素)。谢谢
if ($authorGivenName)
then
    <dc:creator id="author{$i}">{$authorGivenName || ' ' || $authorSurname}
        <meta refines="#author{$i}" property="file-as">{$authorSurname || ', ' $authorGivenName}</meta>,
        <meta refines="#author{$i}" property="role" scheme="marc:relators">aut</meta>,
        <meta refines="#author{$i}" property="role" scheme="onix:codelist17">A01</meta>
    </dc:creator>
else ()