编辑生成的源代码时如何从 Marklogic 数据库中检索数据?

how to retrieve data from a Marklogic database when editing the generated source code?

我想通过添加 select 限制搜索列表来编辑生成的 Marklogic 源代码。生成的代码是 javascript,select 列表应包含从数据库中检索的信息。我是 marklogic 的新手,我不知道该怎么做。

生成的代码:

'<form name="query" id="query">'
    + '<input type="text" id="query-text" value="" autocomplete="off" />'
    + '<button type="submit" class="button" id="update- query">Search</button>'
    + '</form>'
    + '<div id="search-suggestions"></div>';

我想添加这段代码:

     <p>Choose a section: </p>
     <select name="sec-title" id="sec-title">
     <option value="all">all</option>
     {
     for $sec-title in fn:distinct-values(//a:sec-title/text())
     order by $sec-title
     return if($sec-title = xdmp:get-request-field("sec-title"))
     then <option value="{$sec-title}" selected="selected"> {$sec-title}  </option>
     else <option value="{$sec-title}"> {$sec-title} </option>
     }
     </select>

听起来您使用 AppBuilder 制作了示例应用程序。

应该注意的是,AppBuilder 似乎从 ML8 开始被弃用,优先于 Java 和 node.js 中的示例应用程序。对于那些,请参阅 github 以获得 marklogic sample stack

扩展 AppBuilder 应用程序
如果您真的想继续扩展 AppBuilder 应用程序,请参阅 here

导出AppBuilder原代码随意编辑
如果您需要继续使用 AppBuilder 代码,我建议您将整个应用程序的源代码导出到本地目录,然后将其用作您的应用程序的基础。然后你就可以开始编辑了。为此,您将使用 Roxy(the deployer part) and follow the great set of directions here provided by David Casel