Login
Quick Search
showWiki Markup Help

Scripting

by wolf at 10-11-2007 16:29; Wiki ID: Scripting

Using the Script Macro

You can directly embed XQuery code into a wiki entry using the script macro. For example:

renders into:

5 + 4 = 9

A script can access the current HTTP request, response or session and thus evaluate parameters passed in by the user:

Here's a working example using the code above:

Please enter your name!

The XQuery script can also be executed on a database instance running outside the current web application. The XQuery will be posted to the URI specified in the parameter, which should point to eXist's REST interface (usually /rest or /servlet). The trailing part of the URL defines the collection on which the query is executed. For the example above, we simply add an uri attribute, pointing to the local REST interface:

If parameter forward is set to "yes" (the default), the current request parameters will be appened to the server URI and are thus available to the target XQuery. However, the HTTP session or other request properties are not forwarded.

Including External Contents

External contents can be included into an entry by using the include macro:

Loading Entry Contents from an URL

The content of an entry in a feed can also be loaded from an external URL. This is currently not possible through the web interface, though editing an entry manually is easy and can be done with any WebDAV-enabled editor (the WebDAV URL is http://localhost:8000/webdav/db/).

If the content element in the entry has a src attribute, the contents of the entry will be loaded from the URL specified in the attribute. For example:

To generate this, create a dummy entry through the web interface, then open the feed via WebDAV, delete the dummy content and add the src attribute.

Links
Latest Posts
AtomicWiki 0.5