Srophé Application : Documentation
Facets
The Srophé Application provides a partial facet implementation of the EXPath facet specifications (http://expath.org/spec/facet).
Module:
modules/lib/facets.xql
Example facet configuration file: facet-def.xml
<facet-definition name="series" label="Series">
<group-by>
<sub-path>ancestor::tei:TEI/descendant::tei:seriesStmt/tei:title</sub-path>
</group-by>
<max-values show="5">10</max-values>
<order-by direction="ascending">value</order-by>
</facet-definition>
- The name attribute describes the name of the facet.
- Label will become the HTML label.
- group-by element specifies how the facet should behave, in this case the default facet function is used. To create a custom facet you would define it here in the function attribute.
Example:
<group-by function="facet:authors">
(There must then be a matching facet:authors() function in facet.xqm) - The group-by/sub-path describes the relative XPath to the element to be faceted on. Make sure there is a range index (see creating indexes) for the element in this XPath, as it will effect facet performance.
- The max-values element sets how many results to show initially (
@show
) and the maximum number of results to show once expanded. - The order-by element sets the order for the facet, count or value (alphabetical by value)
Range facets are useful to group together values, for example grouping dates by century.
<facet-definition name="Century">
<range type="xs:year">
<bucket gt="1500-01-01" lt="1600-01-01" name="1500-1600" order='6'/>
<bucket gt="1600-01-01" lt="1700-01-01" name="1600-1700" order='5'/>
<bucket gt="1700-01-01" lt="1800-01-01" name="1700-1800" order='4'/>
<bucket gt="1800-01-01" lt="1900-01-01" name="1800-1900" order='3'/>
<bucket gt="1900-01-01" lt="2000-01-01" name="1900-2000" order='2'/>
<bucket gt="2000-01-01" name="2000 +" order="1"/>
</range>
<group-by type="xs:date">
<sub-path>/@syriaca-computed-start</sub-path>
</group-by>
<max-values show="5">40</max-values>
<order-by direction="descending">order</order-by>
</facet-definition>
XQuery functions for displaying facets on an HTML page via eXist-db templating:
app:display-facets($node as node(), $model as map(*), $collection as xs:string?, $facets as xs:string?)
To include on an HTML page:
<div data-template="app:display-facets"/>
A collection parameter may be included, in this case the XQuery will look for a configuration file in the specified home directory for that collection, as established by the repo-config.xml file.
<div data-template="app:display-facets" data-template-collection="places"/>
HTML facets display can be restyled in the resources/css/style.css
.