Examples - xokomola/origami GitHub Wiki

Simple extractor examples

These must be revised for 0.6

extract-1.xq

Demonstrates that xf:extract orders nodes in document order.

See: source

extract-2.xq

Demonstrates that xf:extract returns no duplicates.

See: source

extract-3.xq

Demonstrates that xf:extract returns only the outermost nodes matched by default. Use xf:extract-inner in case you want to select only the inner-most nodes matched. The default is also available as xf:extract-outer.

See: source

Screen scraping - Get code samples from blog post

Defines an extractor that lists all code examples from a blog post.

See: source

Screen scraping - The New York Times

Pick out news stories from the homepage of the New York Times. Based on an example in an Enlive tutorial by David Nolen.

See: source

Identity transform

See: source

A simple transformer - uppercase elements and attributes

Transforms all elements and attributes turning them into uppercase.

See: source

XQuery transformation example from wikibooks

An XSLT-like transformation example. Note that the performance is abysmal. No doubt it can be improved but it does show that this type of transformation is not very well suited for Origami.

See: source

For comparison a working example of the original code. This runs at light-speed compared to my Origami example.

HTML Templating example

An HTML view template composed from different HTML templates. Example described in more detail on my blog.

Standalone: nolen.xq

See: source

Using RESTXQ: nolen_rest.xqm

See: source