First, this only applies when you have a conflicting style in the parent and child document. For example, if your Normal style is black text in the parent document, but blue text in the child document. In that case, we have to choose one of the styles, and which we choose can be controlled by the mechanisms described here. This does not enable you to change any of the styles in the child document. If the style of the child paragraph is the Normal style, it will remain the Normal style, even if the paragraph containing the Import Tag had a different style.
By default, imported child documents bring in their own styles and properties. You can configure your imported templates to use the styles in the parent template instead, so the final output has a consistent look and feel. This article will introduce you to the Parent Formatting sample that ships with AutoTag and show you how to import child documents both with or without the parent document styling.
Before you are able to use the example provided below you will need to first setup your working environment correctly.
- If you are using Windward Version 13 you need to follow these steps
- If you are using Windward Version 14 or higher you need to follow these steps
A basic example ships with Windward in our AutoTag/templates directory. The example consists of three documents.
- Import Master Parent Formatting - Template.docx
- Import Subdocument - Template.docx
- Import SubSubdocument - Template.docx
In our example here, we will be working with the Master Parent Formatting template and the Import Subdocument template.
The parent template contains an Import Tag with the property settings below depending on your version.
Version 13 only
- Import Tag property use-parent-format set to true.
- Note: use-parent-format has no effect in later versions of Windward.
Version 14 and higher
- Import Tag property import.use.child.styles set to true.
The styles are defined in the text and image below.
- Normal style text that is Calibri font and black in color.
- green header background
- orange footer background
The Import Tag in the parent template references an XML node that contains the filename of the child template to be imported, in this case Import Subdocument – Template.docx. The styles are defined in the text and image below.
- Normal style text that is Comic Sans font and red in color.
- yellow header background
- black footer background
You will notice in image below the footer appears as gray because headers and footers are shown as faded when viewed onscreen in Word, but it is really black.
When the parent template is run and the Import Tags are processed the final report is generated with all child templates processed and imported.
- The styles that have the same name, i.e., Normal, will have the changed attributes of that style (Calibri text and black font) applied to each section of text where that style has been set in the child documents.
- The headers and footers of the child documents are also no longer present and have assumed the headers (green) and footers (orange) of the parent template.
At long last our marketing director can rest easy because is no trace of Comic Sans in the final output document!
NOTE: The child template contains another Import Tag reference to another child template, making the final report generation 3 levels deep. We have not shown this child-child template here, but we note it here so you will understand what you are seeing on the last two pages of the document when you work with the AutoTag sample yourself.