How can I find out which model applied?

When looking at the HTML display of a document, you might wonder which <elementSpec> or <model> is generating a certain HTML output. TEI Publisher by default outputs HTML class names, which can help you to figure this out. Let’s assume we want to find out, which elementSpec/model is spitting out the stage instructions in Shakespeare’s Romeo and Juliet: within the browser window, right click on the text to inspect. From the context menu, select Inspect (or the corresponding item in your system language).

How do I navigate to the root of the document in XPath?

Normally you would get to the document-node of the current document by calling root(.) in an XPath within the ODD. This works, but there is a caveat: TEI Publisher will not always pass the entire document to the ODD! For example, if documents are viewed page by page, TEI Publisher will first construct a virtual TEI document containing only the relevant content of the page. This is necessary to make sure the content is well-formed XML.

How can I include elements located elsewhere (in the same or another document)?

For example, it is common practice to keep notes in the back of the document and reference them using ref. When processing the ref, you want to include the note’s content into the note behaviour: <elementSpec mode="change" ident="ref"> <model behaviour="note"> <param name="place" value="'margin'"/> <!-- Look up the note by xml:id --> <param name="content" value="id(substring-after(@target, '#'), root($parameters?root))/node()"/> </model> </elementSpec> Here we use the fn:id XPath function to look up the element whose ID is given in the @target attribute.

Why does my added model not have an effect?

You added another model rule to an elementSpec but it does not seem to have any effect. This might be due to the rules for selecting a model: The processor walks through all models in sequence and stops at the first one which either has a matching @predicate and/or @output or neither of both. Order is important! Therefore you should always place models for specific cases first and the most general (without predicate or output) last.