There is no great difference between using an If
command to include or exclude a few words or letters or to include or exclude a paragraph or group of paragraphs.
Ifs and Elses
Instances where using an If
(or series of If
s and Else
s) would be applicable would be, for example, to include a party’s date of birth when the party is an individual, or to include a longish paragraph describing a company when the party is a company (and exclude the date of birth).
A template snippet might look like this:
«ChooseFromRDBList(PartyType,Individual,Company,Trust)»
«If(PartyType = ‘Individual’)»
Date of birth:«FormatDate(DateOfBirth, “yyyy-MM-dd”)»
«Else()»
Registration Number:«RegistrationNumber»
«End()»
«If(PartyType = ‘Company’)»
Carrying on business as«TypeOfBusiness»
and registered according to the laws of Honduras.
«End()»
In most cases, the If
command used like this will be sufficient to include and exclude the relevant paragraphs depending on the values of data elements entered by the user.
InsertDocument
Sometimes, though, this might not be sufficient, because there are far too many different options from which to choose. For example, if you were setting up a template for a title deed and wanted to have the user choose the title deed conditions, the problem becomes a huge one. This is because just about every property will have its own more or less unique set of title conditions, and to attempt to put “if” logic into a template to handle this situation would be impossible.
For a situation like this, the different clauses (i.e. title deed conditions in this example) would be constructed and saved in an appropriate folder, or set of folders. The user would be required, when they run the template, to choose the clause, or clauses, which the document needs. This is achieved with the InsertDocument
command.
When XpressDox sees the InsertDocument
command in the template it presents the user with a data capture control which, when selected, brings up the XpressDox Explorer. The Explorer is opened at the folder which the template author has configured in the template configuration as the “Library Folder”. (It would, obviously, make sense for the Library folder to be the folder where the clauses have been stored, so that the user doesn’t have to navigate too far to get to the clauses). As long as the files containing the clauses are appropriately named, the user will be able to choose the relevant clauses for the task at hand. (This is where the Explorer’s Template Usage feature would be very useful in guiding a first-time user in their choice of clause).
A snippet of a template using an InsertDocument
command might look like this:
The property described as
«PropertyDescription»
is to be transferred subject to the following conditions:
«ForEach(ConditionClause)»
«InsertDocument(Clause)»
«End()»
Notice that since the «ForEach»
and «End()»
are alone in their own paragraphs, those two paragraphs will not appear in the merged document. This will leave only the clauses selected by the user, suitably numbered.
When inserting documents into other documents in this way the styles of the source and destination documents play an important role. The default formatting option for InsertDocument
(and for IncludeTemplate
, by the way) is Destination. This means that the documents will format as expected as long as the styles in the inserted document match (by name and formatting properties) the equivalent style in the destination document. Depending on how the template and clauses have been constructed, it may be that Source formatting would be preferable. But that takes us into Word styles, which is a topic too vast to be dealt with in this Cookbook.