XQuery 错误 XPST0003 语法错误

XQuery error XPST0003 syntax error

我想查询一个站点并生成 HTML。我是 XQuery 的新手。 我正在使用来自 eXist-db 的 eXide。我尝试使用 oXygen,但在使用 eXist-db 时一直遇到问题。 除此之外,我不明白为什么这段代码在 eXide 中不起作用:

xquery version "3.0";
import module namespace http =  "http://exist-db.org/xquery/httpclient";
import module namespace util =  "http://exist-db.org/xquery/util";

declare option exist:serialize "method=xhtml  media-type=text/html";

let $spreadsheet-url := 'https://docs.google.com/spreadsheets/d/1rNHWMonN4RSnvxMYpkqeGHG_bBz-WpxCI-2_Wc/gviz/ tq?tqx=out:json'



let $spreadsheet-response := http:get(xs:anyURI($spreadsheet-url), true(),  <Headers/>)

let $body :=  util:base64-decode($spreadsheet-response/httpclient:body/text())

let $x :=  parse-json(substring-before(substring-after($body,'('),');'))

let $odk-server:="http//192.168.0.104"

let $amp:="&amp;"

let $gmap-api-key:="AIzaSyCYC9h9pMGGvREo................"

return
    <html>
        <head>
            <title>Results</title>
        </head>
        <body>
            <table>
                <tr>
                    <th>Mapa</th>
                    <th>Detalhes</th>
                </tr>
                {
                    for $data in $x?table?rows?*
                        let $latitude := $data?c(11)?v
                        let $longitude := $data?c(12)?v
                        let $map-url := concat("https://maps.googleapis.com/api/staticmap?center=",$latitude,",", $longitude, $amp, "zoom=18", $amp, "size=400x400", $amp, "markers=color:blue|", $latitude,",",$longitude, $amp,"key=",$gmap-api-key)

                        let $name:= $data?c(8)?v
                        let $age:=$data=?c(9)?v
                        let $date:=$data?c(10)?f
                        let $image:= replace($data?c(15)?v,"http://aggregate.defaultdomain", $odk-server)
                        return
                            <tr>
                                <td><img src='{$map-url}' alt="map"/></td>
                                <td>
                                    <img src='{$image}' height="200" width="200" alt="imagem"/>
                                <p>{$name}</p><p>{$age}</p><p>{$date}</p>
                                </td>
                                <td>
                                </td>
                            </tr>

                }

            </table>

        </body>
    </html>

它在第 34 行给我一个错误,说它是预期的 </table> 并且找到了 *,

下一行末尾有错别字,即$amp"key=".

中变量和字符串之间少了一个逗号
let $map-url := concat("https://maps.googleapis.com/api/staticmap?center=",$latitude,",",
        $longitude, $amp, "zoom=18", $amp, "size=400x400", $amp, "markers=color:blue|",
        $latitude,",",$longitude, $amp"key=",$gmap-api-key)

其他一切似乎在语法上都是正确的。

如果 eXide 不支持语法 $array?* 来获取数组的所有条目,您可以尝试从

重写它
for $data in $x?table?rows?*
[...]

let $rows := $x?table?rows
for $i in 1 to array:size($rows)
let $data := $rows($i)
[...]