Input Data used for the examples

currentView
        <connector type="XMLConnector">
            <parameter name="content"><[CDATA[
<root>
    <child key="1">
        <english>one</english>
        <english>ten</english>
        <english>hundred</english>
    </child>
    <child key="2">
        <english>two</english>
        <english>twenty</english>
    </child>
</root>]]></parameter>
        </connector>

anotherView
        <connector type="XMLConnector">
            <parameter name="content"><[CDATA[
<anotherRoot>
    <anotherChild anotherKey="1">
        <french>un</french>
        <french>dix</french>
        <french>cent</french>
    </anotherChild>
    <anotherChild anotherKey="2">
        <french>deux</french>
        <french>vingt</french>
    </anotherChild>
</anotherRoot>]]></parameter>
        </connector>

Rules examples

Rename an element
Rename element /root/child to /root/newChild.
            <element in="root">
                <element in="child" out="newChild"/>
            </element>
Output
Ignore a subtree
Ignore node /root/child and all its descendant nodes.
            <element in="root">
                <element-ignore in="child"/>
            </element>
Output
Ignore an element (but keep its descendant nodes)
Ignore node /root/child, but keep its descendant nodes.
            <element in="root">
                <element-ignore in="child">
                    <element/>
                </element-ignore>
            </element>
Output
Ignore a subtree, with a condition of self node
Ignore node /root/child when the value of its attribute @key is 1.
            <element in="root">
                <element-ignore in="child" if="@key=1"/>
            </element>
Output
Ignore a subtree, with a condition of child nodes
Ignore node /root/child when the value of at least one of its children starts with letter 'h'.
            <element in="root">
                <element-ignore in="child" if="english[starts-with(text(),'h')]"/>
            </element>
Output
Create a new element
Create a new element under current element /root/child.
            <element in="root">
                <element in="child">
                    <element-create>new_element('newChild', 'myValue')</element-create>
                </element>
            </element>
Output
Join two data views
Copy subtree of view 'anotherView' matching the attribute @key of current element /root/child of current view.
            <element in="root">
                <set variable="anotherView">view('anotherView')/anotherRoot/anotherChild</set>
                <element in="child">
                    <!-- current() refers to the current context (i.e. the element being created), while . refers to <anotherChild> -->
                    <element-create>$anotherView[@anotherKey = current()/../@key]/french</element-create>
                </element>
            </element>
Output
Join two data views (with hash table)
Same as previous example, but using a hash table (may significantly improve execution time).
            <element in="root">
                <set variable="anotherView" index="@anotherKey">view('anotherView')/anotherRoot/anotherChild</set>
                <element in="child">
                    <element-create>find($anotherView, ../@key)/french</element-create>
                </element>
            </element>
Output
Join two data views (with indexed cache)
Same as previous example, but querying the index of the cache of view 'anotherView' (may be useful if view 'anotherView' is too large to fit into memory).
            <element in="root">
                <element in="child">
                    <element-create>view_path('anotherView', concat('/anotherRoot/anotherChild[@anotherKey="',../@key,'"]'))/*/anotherChild/french</element-create>
                </element>
            </element>
Output Note that the XPath is provided as a string in order to be evaluated by view 'anotherView', rather than being evaluated by the current view. See also IndexedCache plugin parameters.
Sort elements
Sort elements <child> by their number of child elements.
            <element in="root">
                <element-ignore in="child"/>
                <element-create>sort_by_number(../child, 'count(english)')</element-create>
            </element>
Output Note that the XPath is provided as a string in order to be evaluated by the function sort_by_number(). Note that Lavoisier will have to load all the data in memory in order to process this template.
Group elements
Group elements <english> by the first letter of their text. Grouping element in streaming is only possible when these elements are sorted according to the grouping criteria. Since the elements are not sorted, we will need to chain 2 templates for this example.
            <element in="root">
                <element-ignore in="child"/>
                <element-create>sort_by_string(../child/english, 'text()')</element-create>
            </element>
            <element in="root">
                <element-create-as-parent out="group" group-by="substring(text(),1,1)">
                    <element in="english"/>
                </element-create-as-parent>
            </element>
Output