Generating file ...

Preloaded XML Data

XML documents stored in the application can be preloaded into variables (or context properties) to access them in template expressions: if the frontmatter of the template contains a data property, it will be processed as an object, mapping variable (or property) names to relative paths into the application. The templating tries to resolve each relative path to an XML document and declares a top-level property in $context with the corresponding name. For example, the frontmatter of profiles/landing-page/templates/index.html includes:

"data": { "landing": "landing/landing.xml" }

This defines a single mapping, though more can be added. landing/landing.xml is a TEI document containing the sections to be rendered for different parts of the landing page. Within the template, information about the document as well as its content can be accessed with $landing or $context?landing. The value of the variable will be a map with the following properties:

content

The root of the document as a document node or the root element of a fragment (when using addressing by id)

path

The relative path to the document

odd

The ODD configured for rendering this document (without the '.odd' suffix)

view

The preferred view (div, page …) configured for the document

Within the template, you can use all XQuery expressions to further process the content. To render all or parts of it via ODD, call the utility function page:transform, e.g.:

<div>[[ page:transform($landing?content, map { (: parameters :) }, $landing?odd) ]]</div>

If the template is evaluated as part of a route addressing an XML document, the associated document will be preloaded by default and will be available as $doc or $context?doc. In this case, you do not need to declare an explicit mapping in the frontmatter.

For example, profiles/docs/templates/pages/osinski.html will be processed when you click on the link to the document Bogactwa mowy polskiej in the TEI Publisher 10 Documentation and Demo application. The template includes metadata about the document in the right sidebar, which is rendered with the following templating fragment:

[% template after %] <details> [[ page:transform($doc?content//tei:teiHeader, map { "mode": "sidebar" }, $doc?odd || ".odd") ]] </details> [% endtemplate %]