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-apps] Image scaling driving me crazy. Can this be scripted?


Hi Philo,

I do not understand, in the last discussion you had with me and Bob Stayton, Bob suggested some XSLT changes to convert the @width attribute set on the image to a @style attribute:

I'm coming to the conclusion that the EPUB3 standard changed after the Docbook epub3 stylesheet was created. The EPUB3 standard is based on XHTML5, and XHTML5 does permit @width on <img> elements. Further evidence of the change is that in the DocBook template that converts banned attributes to style attributes, there is a specific exception carved out for @width on img elements to pass it through to the epub3 output. The comment in the XSL says it is permitted, and I know I've produced epub3 output that passed previous versions of epubcheck without complaining about @width.

So this needs to be updated in the DocBook stylesheet. Could you please file an issue on the Github site for the stylesheets:

https://github.com/docbook/xslt10-stylesheets

In the meantime, I'll describe the source of the problem in case you want to fix it in your stylesheets. In the xhtml5/html5-element-mods.xsl files there is a template that starts with <xsl:template match="*" mode="convert.to.style"> that handles the conversion of hard attributes to styles. The culprit is this line in that template:

 <xsl:when test="local-name() = 'width' and $element != 'img'">

that needs to be changed to:

 <xsl:when test="local-name() = 'width'">

to remove the exception for img elements.

and from your answer I understood that this worked for you.

Regards,

Radu

Radu Coravu
Oxygen XML Editor
On 3/30/21 22:16, Philo Calhoun wrote:
I tried the various suggestions given and still have to do extensive editing of OxygenXML docbook to ePub conversions if image scaling is used.

To demonstrate the issue, here is a simple docbook XML file:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href=""http://docbook.org/xml/5.1/rng/docbook.rng" class="" moz-do-not-send="true">http://docbook.org/xml/5.1/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href=""http://docbook.org/xml/5.1/sch/docbook.sch" class="" moz-do-not-send="true">http://docbook.org/xml/5.1/sch/docbook.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.1">
 Â
<info>
   Â
<title>Figure Scaling</title>
   Â
<author>
     Â
<personname>John Doe</personname>
   Â
</author>
   Â
<author>
     Â
<orgname>ABC Publishing</orgname>
   Â
</author>
 Â
</info>
 Â
<sect1>
   Â
<title>The problem</title>
   Â
<para>Image scaled 25%:</para>
   Â
<para><inlinemediaobject>
       Â
<imageobject>
         Â
<imagedata
            fileref="../../../../../Applications/Oxygen%20XML%20Editor/samples/personal-images/michelle.taylor.jpg" width="25%"
          />
       Â
</imageobject>
     Â
</inlinemediaobject></para>
   Â
<para>Image scaled 50%:</para>
   Â
<para><inlinemediaobject>
       Â
<imageobject>
         Â
<imagedata
            fileref="../../../../../Applications/Oxygen%20XML%20Editor/samples/personal-images/michelle.taylor.jpg" width="50%"
          />
       Â
</imageobject>
     Â
</inlinemediaobject></para>
   Â
<para>Image scaled 75%:</para>
   Â
<para><inlinemediaobject>
       Â
<imageobject>
         Â
<imagedata
            fileref="../../../../../Applications/Oxygen%20XML%20Editor/samples/personal-images/michelle.taylor.jpg" width="75%"
          />
       Â
</imageobject>
     Â
</inlinemediaobject></para>
 Â
</sect1>
</article>

__________________

When this is exported, it looks fine on Apple Books but generates errors on Epubchecker, since width designation is not allowed in theÂePub except as a image.style

The OxygenXML generated ebook looks like this:

<?xml version="1.0" encoding="utf-8"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops"
xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
xmlns:svg="http://www.w3.org/2000/svg"><head><title>Figure Scaling</title>
 Â
<link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
 Â
<meta name="generator" content="DocBook XSL Stylesheets V1.79.2"/></head>
 Â
<body><header/>
   Â
<section class="article" title="Figure Scaling" id="d0e3"><div class="titlepage"><div><div>
     Â
<h1 class="title">Figure Scaling</h1></div><div><div class="author">
       Â
<h3 class="author">John Doe</h3></div></div><div><div class="author">
         Â
<h3 class="author"><span class="orgname">ABC Publishing</span></h3></div></div></div><hr/></div>
     Â
<section class="sect1" title="The problem" epub:type="subchapter" id="d0e13"><div class="titlepage"><div><div>
       Â
<h2 class="title" style="clear: both">The problem</h2></div></div></div>
ÂÂ Â Â Â Â Â Â Â Â
<p>Image scaled 25%:</p>
ÂÂ Â Â Â Â Â Â Â Â
<p><span class="inlinemediaobject"><img src="images/michelle.taylor_987157347.jpg" width="25%"/></span></p>
ÂÂ Â Â Â Â Â Â Â Â
<p>Image scaled 50%:</p>
ÂÂ Â Â Â Â Â Â Â Â
<p><span class="inlinemediaobject"><img src="images/michelle.taylor_987157347.jpg" width="50%"/></span></p>
ÂÂ Â Â Â Â Â Â Â Â
<p>Image scaled 75%:</p><p><span class="inlinemediaobject"><img src="images/michelle.taylor_987157347.jpg" width="75%"/></span></p>
     Â
</section>
   Â
</section>
   Â
<footer/>
 Â
</body>
</html>
______________________

This generates errors for each width designation:

E [EPUBCHeck 4.2.4] Error while parsing file: value of attributeÂâwidthâ is invalid; must be an integer

________________________

To fix this I need to add image styles to the CSS:

img.A{width: 25%;}

img.B{width: 50%;}

img.B{width: 75%;}

I can correct the code, but it requires manually changing each image entry, which is a real issue if one has 100 or so images. The corrected ePub code looks like this:

<?xml version="1.0" encoding="utf-8"?><html xmlns="http://www.w3.org/1999/xhtml"
xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon"
xmlns:ssml="http://www.w3.org/2001/10/synthesis"
xmlns:svg="http://www.w3.org/2000/svg">
 Â
<head>
   Â
<title>Figure Scaling</title>
   Â
<link rel="stylesheet" type="text/css" href="docbook-epub.css"/><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"/></head><body><header/>
     Â
<section class="article" title="Figure Scaling" id="d0e3"><div class="titlepage"><div><div>
       Â
<h1 class="title">Figure Scaling</h1></div><div><div class="author">
         Â
<h3 class="author">John Doe</h3></div></div><div><div class="author">
           Â
<h3 class="author"><span class="orgname">ABC Publishing</span></h3></div></div></div><hr/></div>
       Â
<section class="sect1" title="The problem" epub:type="subchapter" id="d0e13"><div class="titlepage"><div><div>
         Â
<h2 class="title" style="clear: both">The problem</h2></div></div></div>
         Â
<p>Image scaled 25%:</p>
         Â
<p><span class="inlinemediaobject"><img class="A" src="images/michelle.taylor_987157347.jpg"/></span></p>
         Â
<p>Image scaled 50%:</p>
         Â
<p><span class="inlinemediaobject"><img class="B" src="images/michelle.taylor_987157347.jpg"/></span></p>
         Â
<p>Image scaled 75%:</p>
         Â
<p><span class="inlinemediaobject"><img class="C" src="images/michelle.taylor_987157347.jpg"/></span></p>
       Â
</section>
     Â
</section>
     Â
<footer/>
   Â
</body>
</html>

Is there a way of scripting this?

  







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