Template types
There are four types of templates:
Layout templates
Each interviewing template file defines one page layout. However, this does not necessarily mean that you have to create a completely new template file if you want to vary just one aspect of the layout for a particular part of an interview or for a different project. If the basic page layout is the same, you may find that creating one or more sub-templates for the aspects that vary is the way to go.
Sub-templates
A sub-template is a template file that defines the layout of one component of the page. You can create sub-templates for questions (question and response texts), errors, banners, navigation bars, and grids. The main page layout template contains a basic tag indicating where the various components belong and the sub-templates define the exact layout for each component. You specify which sub-templates are to be used by naming them in the routing section of the interview script or in the main layout template.
During interviews, the sub-template is inserted in the page only if required: if an item is not used on a page then the sub-template for that item is not inserted. One example of when sub-templates are handy is errors. If you would like an animated image to appear next to any errors, you cannot use the main template because the image will appear whether an error is present or not. However, if you create an Error sub-template that contains the image, then if there are no errors, the sub-template will not be inserted and the image will not appear.
You can create sub-templates for individual questions, so that just the appearance of those questions differs from the rest of the interview. For example, if you have a question that asks for a cost or price, you can define a template that displays a currency symbol in front of the input box and then apply the template to that question only. In this way you achieve the effect you want without having to alter the basic template for other questions.
Localized templates
With localized templates, you can set the language of an interview based on the respondent’s browser language, and the language can be changed in the interview script. The interviewing program passes the language to the HTML Player, which searches for the appropriate template in the language folder and then in the project folder.
For example, if the language is passed as “en–us”, the HTML Player looks for the localized template in the following folders:
▪Project folder\en–us
▪Project folder\en
▪Project folder
▪Global templates folder\en–us
▪Global templates folder\en
▪Global templates folder
Grid templates
An alternative to defining styles in the metadata or routing section. For more information, see
Grid templates.
XSL templates
The HTML Player uses XSLT to create HTML source output. It uses the Player XML as input, and retrieves relevant information from the Player XML. The source HTML is then transformed by the relevant XSL templates. The
‘Default XSL templates’ on page 651 and the
‘Intermediate XML schema’ on page 672 are provided to assist in the customization of XSL templates. The HTML Player has three default XSL templates:
Label.xsl
Transforms the HTML source for banners, label and error messages on an interview page when a custom Label.xsl template is not defined in the default layout template.
Question.xsl
Transforms the HTML source for question controls on an interview page when a custom Question.xsl template is not defined in the default layout template.
Navigation.xsl
Transforms the HTML source for navigation buttons on an interview page when a custom Navigation.xsl template is not defined in the default layout template.
See also