On 4/13/21 10:56 AM, Gerd Wagner wrote:
Am 4/13/2021 um 9:34 AM schrieb Hussein Shafie:
On 4/12/21 9:59 PM, Gerd Wagner wrote:
The default DocBook-to-HTML conversion in XXE creates PNGs in the target document from the source document's SVGs.

How can I change this if I want to preserve the SVG images in the generated HTML?



Which version of DocBook do you use? 4.x? 5.0? 5.1? I need to know this to give you an accurate "recipe".


I'm using DB 5.0, but could probably also switch to 5.1, if it would simplify the matter.

Thanks,
Gerd



The simplest for you is to replace stock <XXE_V9_install_dir>/addon/config/docbook5/docbook5_convert_input.incl by attached, modified version of this file.

The differences between these two versions of docbook5_convert_input.incl are shallow:

$ diff docbook5_convert_input.incl.STOCK docbook5_convert_input.incl
---
21c21
<                      xpath="//db5:imagedata/svg:svg" toDir="raw">
---
>                      xpath="//db5:imagedata/svg:svg" toDir="resources">
23c23
<                          value="resources/{$url.rootName}.png" />
---
>                          value="resources/{$url.rootName}.svg" />
46c46
<         <resources include="image" match=".+\.(png|jpg|jpeg|gif)"
---
>         <resources include="image" match=".+\.(png|jpg|jpeg|gif|svg)"
---

Note that the above changes will have an effect on, not only DocBook 5 conversion to multi-page HTML, but also to single page HTML and to Web Help.

We will make all DocBook (all versions) to HTML (all variants) conversions in future versions of XXE preserve SVG rather than convert this format to PNG. Nowadays all browsers support SVG really well.



<?xml version='1.0' encoding='ISO-8859-1'?>
<configuration
  xmlns="http://www.xmlmind.com/xmleditor/schema/configuration";
  xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration";>

  <!-- ====== Common to most HTML-based conversions ====================== -->

  <command name="{db5}toHTML.step0">
    <process>
      <mkdir dir="raw" />
      <mkdir dir="resources" />

      <copyDocument filterDuplicateIDs="true" to="__doc.xml">
        <!-- =================================================================
             Support for DocBook 5 imagedata/svg:svg, imagedata/mml:math
             and *equation/mml:math.
        ================================================================== -->
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:svg="http://www.w3.org/2000/svg";
                     xpath="//db5:imagedata/svg:svg" toDir="resources">
          <cfg:attribute name="fileref" 
                         value="resources/{$url.rootName}.svg" />
        </cfg:extract>
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:mml="http://www.w3.org/1998/Math/MathML";
                     xpath="//db5:imagedata/mml:math" toDir="raw">
          <cfg:attribute name="fileref" 
                         value="resources/{$url.rootName}.png" />
        </cfg:extract>
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:mml="http://www.w3.org/1998/Math/MathML";
                     xpath="//db5:equation/mml:math |
                            //db5:informalequation/mml:math |
                            //db5:inlineequation/mml:math" toDir="raw">
          <db5:imagedata fileref="resources/{$url.rootName}.png" />
        </cfg:extract>

        <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />

        <resources include="text" match=".+" 
                   resolve="true" />

        <resources include="image" match=".+\.(png|jpg|jpeg|gif|svg)" 
                   copyTo="resources" />
        <resources include="image" match="(?:.+/)?(.+)\.(\w+)"
                   copyTo="raw" referenceAs="resources/$1.png" />

        <resources exclude="text image" match=".+" 
                   copyTo="resources" />
      </copyDocument>

      <convertImage from="raw" to="resources" format="png" />
    </process>
  </command>

  <!-- =================================================================== -->

  <command name="{db5}toEpub.step0">
    <process>
      <mkdir dir="raw" />
      <mkdir dir="images" />

      <copyDocument filterDuplicateIDs="true" to="__doc.xml">
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:svg="http://www.w3.org/2000/svg";
                     xpath="//db5:imagedata/svg:svg" toDir="raw" >
          <cfg:attribute name="fileref" 
                         value="images/{$url.rootName}.png" />
        </cfg:extract>
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:mml="http://www.w3.org/1998/Math/MathML";
                     xpath="//db5:imagedata/mml:math" toDir="raw" >
          <cfg:attribute name="fileref" 
                         value="images/{$url.rootName}.png" />
        </cfg:extract>
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:mml="http://www.w3.org/1998/Math/MathML";
                     xpath="//db5:equation/mml:math |
                            //db5:informalequation/mml:math |
                            //db5:inlineequation/mml:math" toDir="raw" >
          <db5:imagedata fileref="images/{$url.rootName}.png" />
        </cfg:extract>

        <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />

        <resources include="text" match=".+" 
                   resolve="true" />

        <resources include="image" match=".+\.(png|jpg|jpeg|gif)" 
                   copyTo="images" />
        <resources include="image" match="(?:.+/)?(.+)\.(\w+)"
                   copyTo="raw" referenceAs="images/$1.png" />

        <resources exclude="text image" match=".+" 
                   copyTo="images" />
      </copyDocument>

      <convertImage from="raw" to="images" format="png" />
    </process>
  </command>

  <!-- =================================================================== -->

  <command name="{db5}toRTF.step0">
    <process>
      <mkdir dir="raw" />
      <mkdir dir="resources" />

      <copyDocument filterDuplicateIDs="true" to="__doc.xml">
        <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />

        <resources include="text" match=".+" 
                   resolve="true" />

        <resources include="image" 
                   match=".+\.(png|jpg|jpeg|gif|bmp|wmf|emf|mml|svg)" 
                   copyTo="resources" />
        <resources include="image" match="(?:.+/)?(.+)\.(\w+)"
                   copyTo="raw" referenceAs="resources/$1.png" />

        <resources exclude="text image" match=".+" 
                   copyTo="resources" />
      </copyDocument>

      <convertImage from="raw" to="resources" format="png" />
    </process>
  </command>

  <!-- =======================================================================
       In terms of MathML support, what follows has been designed for 
       Apache FOP + JEuclid
  ======================================================================== -->

  <command name="{db5}toPS.step0">
    <process>
      <mkdir dir="raw" />
      <mkdir dir="resources" />

      <copyDocument filterDuplicateIDs="true" to="__doc.xml">
        <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />

        <resources include="text" match=".+" 
                   resolve="true" />

        <resources include="image" 
                   match="(?:.+/)?(.+)\.(png|jpg|jpeg|gif|mml|svg|svgz%1)" 
                   copyTo="resources" referenceAs="resources/$1.$2" />
        <resources include="image" match="(?:.+/)?(.+)\.tex"
                   copyTo="raw" referenceAs="resources/$1.%0" />
        <resources include="image" match="(?:.+/)?(.+)\.(\w+)"
                   copyTo="raw" referenceAs="resources/$1.png" />

        <resources exclude="text image" match=".+" 
                   copyTo="resources" />
      </copyDocument>

      <convertImage from="raw" to="resources" format="%0 png" />
    </process>
  </command>

  <!-- =======================================================================
       In terms of MathML support, what follows has been designed for 
       RenderX XEP + JEuclid. Comment out what's above and uncomment out
       whar follows if you need to process documents containing MathML
       using RenderX XEP.
       Note that embedded MathML is supported here only inside imagedata. 
       It is not supported here inside equation, informalequation, etc.

  <command name="{db5}toPS.step0">
    <process>
      <mkdir dir="raw" />
      <mkdir dir="resources" />

      <copyDocument filterDuplicateIDs="true" to="__doc.xml">
        <cfg:extract xmlns=""
                     xmlns:db5="http://docbook.org/ns/docbook";
                     xmlns:mml="http://www.w3.org/1998/Math/MathML";
                     xpath="//db5:imagedata/mml:math" toDir="raw">
          <cfg:attribute name="fileref" value="resources/{$url.rootName}.svg" />
        </cfg:extract>

        <resources match="^[a-zA-Z][a-zA-Z0-9.+-]*:/.+" />

        <resources include="text" match=".+" 
                   resolve="true" />

        <resources include="image" 
                   match="(?:.+/)?(.+)\.(png|jpg|jpeg|gif|svg|svgz%1)" 
                   copyTo="resources" referenceAs="resources/$1.$2" />
        <resources include="image" match="(?:.+/)?(.+)\.mml"
                   copyTo="raw" referenceAs="resources/$1.svg" />
        <resources include="image" match="(?:.+/)?(.+)\.tex"
                   copyTo="raw" referenceAs="resources/$1.%0" />
        <resources include="image" match="(?:.+/)?(.+)\.(\w+)"
                   copyTo="raw" referenceAs="resources/$1.png" />

        <resources exclude="text image" match=".+" 
                   copyTo="resources" />
      </copyDocument>

      <convertImage from="raw/*.mml" to="resources" format="svg" />
      <convertImage from="raw" skip="mml" to="resources" format="%0 png" />
    </process>
  </command>
  ======================================================================== -->

</configuration>
--
XMLmind XML Editor Support List
xmleditor-support@xmlmind.com
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to