Categories > OpenTBS with DOCX >

Load sub-template in DOCX

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: BuDuS
Date: 2014-12-16
Time: 08:39

Load sub-template in DOCX

Hello

I have a template in docx format.
If I use variable substitution like
[onshow.variable]
it's work perfectly.
But, If I try to load a sub-template like this:
[onload;file=sub_template.docx]
the output docx may result corrupted.

The same result is with other format, like odf.

Where I wrong ?
By: Skrol29
Date: 2014-12-16
Time: 23:21

Re: Load sub-template in DOCX

A DOCX is a made of XML sub-files.
So a sub-template must an XML file.
That's why it is quite difficult to use sub-templates with OpenTBS.
By: BuDuS
Date: 2014-12-17
Time: 15:34

Re: Load sub-template in DOCX

Thanks for the answer !!!

I need to split one DOCX template into several sub-template; the first piece is customized (content and sub-template to load) and load the sub-template conditionally.

Example:

DOCX is a TEMPLATE_A and contain 3 sub-contents.

split TEMPLATE_A in TEMPLETE_A_SPLIT DOCX and  CONTENT_1 XML, CONTENT_2 XML, CONTENT_3 XML
copy TEMPLETE_A_SPLIT in TEMPLETE_B_SPLIT
copy TEMPLETE_A_SPLIT in TEMPLETE_C_SPLIT

manually modify copy of TEMPLETE_B_SPLIT like this:

[onload;file=CONTENT_1.xml]
[onload;file=CONTENT_3.xml]

manually modify copy of TEMPLETE_C_SPLIT like this:

[onload;file=CONTENT_2.xml]
[onload;file=CONTENT_3.xml]

***

Is it right and possible with XML load ?
By: Skrol29
Date: 2014-12-17
Time: 23:59

Re: Load sub-template in DOCX

Hi,

I don't really understand what you're trying to produce at the end.
Can't you simply use conditional block instead of sub-template ?
By: BuDuS
Date: 2014-12-18
Time: 19:54

Re: Load sub-template in DOCX

mmm, In other words:

- I have many (aproximately 150) templates ("original") in DOCX format
- Some parts of this templates are common

I need to:

- manually extract non common parts (aproximately 150) and save them to a many "master" template files
- manually extract the commons parts and save them in a many files, the "sub-template" part

Manually, in the "master" template, load the "sub-template" with code like:
[onload;file=my-sub-template-xyz.???]

The "master" template can contain from one to many load of sub-template but, the "sub-template", is always extracted from the same "original" template (can this exclude ID and Style problems ?).

With OpenTBS I load "master" template and it perform "merge" when occur the "[onload]" fields.

Thank, Andrea.
By: Skrol29
Date: 2014-12-19
Time: 01:50

Re: Load sub-template in DOCX

> the "sub-template", is always extracted from the same "original" template (can this exclude ID and Style problems ?)

You will probably have ID and Style problems if the main template and the sub-templates have not the same original DOCX.

If you use sub-templates, those sub-template cannot be the complete "content.xml" content.
A sub-template must be an extract of <w:p> elements, or tables.
Images cannot be given with a sub-template because they are additional sub-files in the DOCX.

In the main DOCX template, the sub-template must be called like this :
[onload;file=my-sub-template-a.xml;enlarge=tbs:p]

In my point of view I think conditional blocks in the main template should be more simple to build and to maintain than sub-templates.
By: BuDuS
Date: 2014-12-19
Time: 20:38

Re: Load sub-template in DOCX

I'm not sure that the block condition is the best choice, but I try it.

In the template I write the code like this:

[onshow; block=begin; enlarge=tbs:p; when [var.condition == 'default']
....
....
....
[onshow; block=end; enlarge=tbs:p]

and this works.

But I have many templates (hundreds) with many difference.
The "include" solution (like programming languages) seems to be a powerful solution for my problem; the "condition" solution is good for one template that include sequentially variants but I have too many "master template" to merge into one only.

I thank you for the patience and the answer !