4.3. Conditional processing

XMLmind Ebook Compiler can conditionally exclude some contents found in the ebook specification or in the input HTML pages. To put this feature into use, the ebook author must:

  1. Specify one or more data-* attributes on the elements to be conditionally excluded. Examples: data-edition="complete", data-output-format="docx odt pdf rtf wml".

    These data-* attributes are often called profiling attributes because they are used to define several profiles for the same document.

    It's up to the ebook author to choose the names and allowed values for the profiling attributes.

    The ebook author may allow only a single value for a given profiling attribute. Example: attribute data-edition may contain only a single value, one of "complete" or "abridged".

    Or, on the contrary, the ebook author may allow a given profiling attribute to contain several values separated by space characters. Example: attribute data-output-format may contain one or more of "docx", "epub", "frameset", "html ", "odt", "pdf", "rtf", "webhelp", "wml".

  2. Pass one or more profile.* parameters to the ebookc command-line option. These profile.* parameters must match the chosen profiling attributes. Example: -p profile.edition abridged -p profile.output-format pdf.

    Note that unless you pass a profile.* parameter, the corresponding data-* attribute is not given any special meaning by XMLmind Ebook Compiler. For example, without -p profile.output-format VALUE, attribute data-output-format is considered to be just an ordinary attribute.

How some elements are conditionally excluded by XMLmind Ebook Compiler is best explained by an example:

Example 4-1. Example of conditional processing
1
2
3
4
5
6
7
8
9
10
<p>See YouTube demo:</p>

<p data-edition="complete" data-output-format="epub frameset html webhelp">
<iframe src="https://www.youtube.com/embed/6MgZBZ4XHzU"
height="360" width="640"></iframe></p>

<p data-edition="complete" data-output-format="docx odt pdf rtf wml">
<img src="images/YouTube_play_icon.svg" alt="..."/> 
<a href="https://youtu.be/6MgZBZ4XHzU"
target="_blank">https://youtu.be/6MgZBZ4XHzU</a>.</p>

See YouTube demo:

YouType Play icon https://youtu.be/6MgZBZ4XHzU.

For an element to be excluded, suffice for a single profiling attribute to be “excluded”. A profiling attribute data-X is “excluded” if none of the values it contains matches a value contained in the profile.X parameter passed to ebookc.

For example, with -p profile.edition complete -p profile.output-format pdf, the embedded video

1
2
3
<p data-edition="complete" data-output-format="epub frameset html webhelp">
<iframe src="https://www.youtube.com/embed/6MgZBZ4XHzU"
height="360" width="640"></iframe></p>

is excluded because despite the fact that data-edition="complete" is “included”, data-output-format="epub frameset html webhelp" is “excluded”.

Other examples, if you pass ebookc