-1

我在我的 XQuery 文件中创建了一个 HTML 按钮。我只是想知道单击文件时如何调用文件的 XQuery 函数?

xquery version "1.0";
declare option exist:serialize "method=xhtml media-type=text/html";
declare function local:fn($str as xs:string) as xs:string
{
   ...
};

<html>
...
<input type="submit" onclick=" ? "/>
</html>

我试过 :

<input type="submit" value="Search" onclick="{local:fn()}"/>

但是没有用。

4

1 回答 1

1

您可以在http://www.xqib.org/js/OnClickEvent.html找到一个示例

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>   
    <title>XQIB: Sample page</title>
    <meta charset="UTF-8"/>
    <script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
    <script type="application/xquery">
      declare sequential function local:listener($loc, $evtObj) {
        b:alert("Hello, World")
      };

      b:addEventListener
        (b:dom()//input[@id="myButton"], "onclick", local:listener#2)
    </script>
  </head>
  <body>
    <h1>Onclick Event</h1>
    <input id="myButton" type="button" value="Click me"/>
  </body>
</html>
于 2012-12-24T11:11:57.420 回答