OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: RE: Docbook XML to Epub


For the first question, it's usually pretty easy to solve this problem.Â
In many cases, in the XML you can just add a role="red" attribute to the docbook element, ex.Â
<para role="red">This is red </para>
and then use this: p {color: red} in the css.Â


If I want all the text in a chapter to be a certain color, I'll assign a value to xml:id inside CHAPTERÂ
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
  version="5.0" xml:id="red">

then use this css:Âsection#red {
color: #red;
margin: 0em 2em 0em 2em;}

_______________________________________________________
The second problem is more difficult, and my solution has worked for me but with a limitation.ÂBy the way, in my example I am using MEDIAOBJECT instead of
INLINEMEDIAOBJECT, but I am assuming they are functionally equivalent.

First, it looks like if you use the width as an attribute in imagedata, docbook xsl outputs a table containing the image. I can't remember if that throws an epub error, but if probably isn't supported on kindle especially.Â

Instead ÂI use a xml:id on the chapter element. That lets me write css specific to the div container for any image in the chapter.ÂÂ
ÂÂ
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
  version="5.0" xml:id="dogchapter">ÂÂ
...
 Â<mediaobject role="dog">
    <imageobject>
      <imagedata fileref="images-epub/1200dog.jpg"/>
    </imageobject>
    <textobject>
      <phrase> Illustration: Dog Orientation</phrase>
    </textobject>
  </mediaobject>

The output will look like this:

....
<section class="chapter" title="Dog Orientation" epub:type="chapter" id="dogchapter">
...
Â<div class="mediaobject"><img src="" alt="Illustration: Dog Orientation"/></div>

That allows the css to reference the chapter's unique ID which is dogchapter to customize the DIV --> MEDIAOBJECT. Â


Âsection#dogchapter div.mediaobject {
Âwidth: 95%;
    display: block;
 margin-left: auto;
 margin-right: auto;  Â
}

Âimg {
    display: block;
 margin-left: auto;
 margin-right: auto; Â
}

This css code works very well on Kindle -- adjust your percent as needed.

But here's the catch -- Even though the mediaobject in my example has role="dog", the output DIV doesn't contain this reference at all. (Apparently Docbook XSL converts the MEDIAOBJECT to DIV class=mediaobject" I can only use chapter xml:id="dogchapter".

As long as I have no more than one image per chapter -- or use the same css for every image in the chapter, I'm fine. But if it's more than one with different widths, then I'm stuck.

I'd appreciate any ideas about how to allow for different css for several images in a single chapter.ÂÂ

Robert Nagle
Personville Press
Katy TXÂ
ÂÂ




From:ÂPhilo Calhoun <island@luxsci.me>
To:Âdocbook-apps@lists.oasis-open.org
Cc:Â
Bcc:Â
Date:ÂWed, 24 Mar 2021 15:43:38 -0700
Subject:ÂDesignations in docbook for conversion to ePub
I have a well formed book in docbook XML format. I was wondering how to solve two issues:

First, what designation can I use for color attributes for text? I would like it to convert over to EPub3 with a CSS that has something like span.red {font-color: red;}

Second, I have several images with specified widths in the XML file, coded like:

Â<para><inlinemediaobject>
 ÂÂ
<imageobject>
ÂÂ ÂÂ
<imagedataÂfileref=âfigures/TestImage.jpg"Âwidth="50%"/>
 ÂÂ
</imageobject>
ÂÂÂ
</inlinemediaobject></para>

This is fine in docbook but when I convert this to ePub, it generates ePub errors - as XHTML cannot specify image width directly. To be error free, I need to specify with width Âthrough a CSS designation like img.half where img.half is set to 50% width in the CSS. Is there a way in Oxygen XML to specify a designation in docbook that will at least tag these images so that I can add the CSS specification for width?

--
Robert Nagle
5115 Sandyfields Ln Katy, TX 77494
(Cell) 832-251-7522


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]