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:
- 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
". - Pass one or more
profile.*
parameters to theebookc
command-line option. Theseprofile.*
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 correspondingdata-*
attribute is not given any special meaning by XMLmind Ebook Compiler. For example, without-p profile.output-format VALUE
, attributedata-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:
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:
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
- no
profile.*
parameter at all, the above example will contain both the embedded video and the YouTube link to the video. -p profile.edition abridged
, the above example will contain neither the embedded video nor the YouTube link to the video.-p profile.edition complete
, the above example will contain both the embedded video and the YouTube link to the video.-p profile.output-format epub
, the above example will contain just the embedded video.-p profile.output-format pdf
, the above example will contain just the YouTube link to the video.-p profile.edition abridged
-p profile.output-format pdf
, the above example will contain neither the embedded video nor the YouTube link to the video.-p profile.edition complete
-p profile.output-format pdf
, the above example will contain just the YouTube link to the video.-p profile.edition complete
-p profile.output-format "epub pdf"
, the above example will contain both the embedded video and the YouTube link to the video.