gpt4 book ai didi

xml - 除非我在oXygen上手动编辑文件,否则eXist-db不会对通过XQuery更新插入添加的新记录进行索引(“看到”)

转载 作者:行者123 更新时间:2023-12-03 16:50:50 30 4
gpt4 key购买 nike

我正在CentOS 7.4.1708(核心),Java(TM)SE运行时环境(内部版本1.8.0_152-b16)上运行eXist-db 3.6.1。我希望能够在person.xml中的最后一个记录之后添加一个新记录,如下所示:

<person xml:id="pe0472"> [...] </person>
<person xml:id="pe0473"> [...] </person>


我在app.xql中的函数内有一个html表单,该表单通过editpers.html中的 data-template调用,它可以获取数据:

declare function app:newpers($node as node(), $model as map(*), $searchkey as xs:string?)

{

let $surname := doc(concat($config:app-root, '/input/persons.xml'))//tei:listPerson/tei:person[@xml:id=$searchkey]/tei:persName/tei:surname

[...]

return

<div class="container">

<form action="add.html" method="POST">

<div class="form-group">

Surname:<br/>
<input type="text" name="surname" value="{$surname}"/>
[...]
<input class="btn btn-default" type="submit" value="Submit"/>
</div>
</form>
</div>
};


表单的提交发送到add.html,该文件通过 data-template引用了app:addpers函数:

declare function app:addpers($node as node(), $model as map(*)) {

let $peid := request:get-parameter('peid', '')
let $surname := request:get-parameter('surname', '')
[...]
let $on-disk := doc(concat($config:app-root, '/input/persons.xml'))

let $insert := update insert

<person xml:id="{$peid}" >
<persName xmlns="http://www.tei-c.org/ns/1.0">
<surname>{$surname}</surname>
[...]
</persName>
</person>

following $on-disk//tei:person[@xml:id][last()]

return

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Added</title>
</head>
<body>
<div>
<h3>Success!</h3>
</div>
</body>
</html>

};


我得到了很好的消息,如果我在oXygen中打开master person.xml文件,则可以看到很好地添加了新记录。但是,它没有显示在我的网页中,该网页显示了通过此查询显示的所有记录:

declare function app:listPers($node as node(), $model as map(*)) {

for $person in doc(concat($config:app-root, '/input/persons.xml'))//tei:listPerson/tei:person
return

<tr>
<td>{$person/tei:persName/tei:forename}</a></td>
</tr>
};


这显示所有记录,但不显示通过app:addpers函数添加的最新记录。刷新浏览器上的缓存,这在我使用以下方法更新现有记录的值时会有所帮助:

let $update := update value $on-disk//tei:person[@xml:id eq $peid]/tei:persName/tei:surname with $surname


(直到我清除缓存后,才会显示已编辑的记录)对这次没有帮助。

为了在前端显示新记录(app:listPers),是对oXygen中的主文件做一些愚蠢的事情(例如,在任意位置添加和删除空间,然后保存它),新记录将神奇地出现在我的浏览器页面上。这是预期的行为吗?我觉得这很令人困惑,而且我想不出其他办法可以解决此问题。

我已经在Firefox 58.0.1和Safari 11.0.3上进行了测试。

最佳答案

目前,我的解决方法是添加一个

    <script type="text/javascript">
window.addEventListener('load', function (e) {
window.applicationCache.addEventListener('updateready', function (e) {
window.location.reload(true);
}, false);
console.log("loaded");
}, false);
</script>


到受影响页面的开头,这将强制页面的重新缓存,而无需手动进行。

关于xml - 除非我在oXygen上手动编辑文件,否则eXist-db不会对通过XQuery更新插入添加的新记录进行索引(“看到”),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48626865/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com