<< Index

XQuery Calling JavaScript

Page | Source
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>   
    <title>XQIB: Sample page</title>
    <meta charset="UTF-8"/>
    <link href="style.css" rel="stylesheet" type="text/css">
    <script type="application/xquery" src="module.xquery"></script>
    <script type="text/javascript">
	  foo = function (arg1){ return 'the text was ' + arg1;};
    </script>
    <script type="application/xquery">
	  let $x := b:js-call(
	    'window.foo',
	    string(b:dom()/id('a')/text())
	  )
	  return
	  replace value of node b:dom()/id('a') with $x
    </script>
  </head>
  <body>
    <h1 id='a'>Some text.</h1>
  </body>
</html>