relative images with xinclude problem

Here should go questions about transforming XML with XSLT and FOP.
jdoklovic
Posts: 6
Joined: Fri May 22, 2009 5:46 pm

relative images with xinclude problem

Post by jdoklovic »

I can't seem to get relative images to work with xinclude.
They show up in the editor fine, but not in the resulting pdf.

My project setup is:
MyProject
-- docs
---- basedoc.xml
---- section
------ section1.xml
---- images
------ image1.png

When I run the transform, I get:

Code: Select all

SEVERE: Image not found: file:/home/jdoklovic/data/eclipse/MyProject/docs/section//home/jdoklovic/data/eclipse/MyProject/docs/images/image1.png
I have the Base URI fix up enabled and keep relative image paths param set to 0.
I'm using the apache FOP with JAI

What am I missing?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: relative images with xinclude problem

Post by sorin_ristache »

Hello,

Do you have an xml:base attribute on an element in your XML document? What stylesheet do you apply? Is it a DocBook document? Can you post a small sample file?


Regards,
Sorin
jdoklovic
Posts: 6
Joined: Fri May 22, 2009 5:46 pm

Re: relative images with xinclude problem

Post by jdoklovic »

It's a docbook book with chapters and sections included with xinclude.
I do not have an xmlbase attribute. Where should this attribute appear and what should it's value be?

here's my stlysheet. Note that the import of the docbook.xsl is the fo/docbook.xsl that ships with oxygen:

Code: Select all

<?xml version='1.0'?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="http://docbook.sysbliss.com/fo/docbook.xsl"/>
<xsl:param name="local.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
<l:l10n language="en">
<l:gentext key="Chapter" text="Boo"/>
<l:gentext key="chapter" text="Boo"/>
</l:l10n>
</l:i18n>
</xsl:stylesheet>
here's my main docbook file:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng" type="xml"?>
<book xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
<info>
<title>My Book</title>
<subtitle>Version 1.0.0-beta2</subtitle>
</info>
<xi:include href="intro/introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="install/installation.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="interface/basics.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="workflows/working-with-workflows.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="status/working-with-statuses.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="steps/working-with-steps.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="transitions/working-with-transitions.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</book>
Here's the installation.xml included from above:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng" type="xml"?>
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">

<title>Installation</title>
<xi:include href="sysreqs.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="install-jars.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="license.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</chapter>
and here's license.xml included that has images:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?oxygen RNGSchema="http://www.oasis-open.org/docbook/xml/5.0/rng/docbookxi.rng" type="xml"?>
<sect1 xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
<title>Entering Your License Info</title>
<para>... omitted ...</para>

<figure>
<title>License Navigation</title>
<mediaobject>
<imageobject><imagedata width="180" contentdepth="114" scalefit="1" fileref="../images/license_link.png"/></imageobject>
</mediaobject>
</figure>

</sect1>
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: relative images with xinclude problem

Post by sorin_ristache »

Hello,

I created a folder images in the same folder that contains the main XML file and the install folder. I created a new transformation scenario associated with the main XML file that applies your DocBook FO customization stylesheet. Of course I replaced the path http://docbook.sysbliss.com from your example with a valid path that can be resolved to the DocBook stylesheets (for example I can replace http://docbook.sysbliss.com with http://docbook.sourceforge.net/release/xsl/current which will be resolved by the default XML catalog of Oxygen to the built-in DocBook XSL stylesheets that come with Oxygen 10.2, that is DocBook XSL version 1.74.3). With this folder structure the image license_link.png from folder images is included in the result PDF document generated by the built-in FOP processor. I will send you a zip archive by email with the files that I created from your samples so that you can test on your computer. Does it work on your computer?


Regards,
Sorin
jdoklovic
Posts: 6
Joined: Fri May 22, 2009 5:46 pm

Re: relative images with xinclude problem

Post by jdoklovic »

yeah, that worked, thanks.
I was also able to switch my project to use apache FOP (instaed of the custom JAI processor i was using) and saxon. It's all working now.

I still have a problem with scaling images though... not matter what i try for attributes in the image data tag, all images that are smaller than the available area are stretched to fit. I want them to be the original size.

i.e.

Code: Select all

<imagedata width="180" contentwidth="180" depth="114" contentdepth="114" scalefit="0" fileref="../images/license_link.png" format="PNG"/>
gets scaled up.

Thanks again.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: relative images with xinclude problem

Post by sorin_ristache »

jdoklovic wrote:I still have a problem with scaling images though... not matter what i try for attributes in the image data tag, all images that are smaller than the available area are stretched to fit. I want them to be the original size.
Do you mean the image is scaled to 180 x 114 pixels? What is the original size of the image? If the original size is not 180 x 114 I think you should not use these attributes.


Regards,
Sorin
jdoklovic
Posts: 6
Joined: Fri May 22, 2009 5:46 pm

Re: relative images with xinclude problem

Post by jdoklovic »

the original size is 180x114
The problem is that even with these attributes, the image is being stretched to fit the available space (width wise) which is much larger than the original image dimensions.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: relative images with xinclude problem

Post by sorin_ristache »

Do you mean the image is stretched horizontally to the whole width of the PDF page? Apache FOP has some image scaling problems but I don't remember that it stretches the image to the whole width of the page in the PDF result. Can you post a small sample of the XML file and send the image file to see if it is one of the FOP image scaling problems?


Regards,
Sorin
jdoklovic
Posts: 6
Joined: Fri May 22, 2009 5:46 pm

Re: relative images with xinclude problem

Post by jdoklovic »

using apache FOP.

Code: Select all


<title>Entering Your License Info</title>
<para>If you have purchased the Jira Workflow Designer, a license should have been emailed to
you.</para>
<para>To apply your license to your installation, navigate to the <emphasis role="bold"
>Administration</emphasis> section of Jira.</para>
<para>Under the <emphasis role="bold">System</emphasis> section in the left navigation, click on
the <emphasis role="bold">Workflow Designer License</emphasis>. link.</para>
<informalfigure>
<mediaobject>
<imageobject><imagedata width="180" contentwidth="180" depth="114" contentdepth="114" scalefit="0" fileref="../images/license_link.png" format="PNG"/></imageobject>
</mediaobject>
<caption><simpara>Update License Navigation</simpara></caption>
</informalfigure>
sent original image and screenshot of resulting pdf at 100% to support.
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: relative images with xinclude problem

Post by sorin_ristache »

Hello,

Thank you for the files. I was afraid that the image was scaled to the full width of the page but that does not happen. The width of the image is larger in the PDF than the real image (about twice the real width of the image) and it is the old image scaling problem in Apache FOP that was not fixed yet.


I hope this helps,
Sorin
jdoklovic
Posts: 6
Joined: Fri May 22, 2009 5:46 pm

Re: relative images with xinclude problem

Post by jdoklovic »

is there any workaround?
Maybe using a different FOP processor?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: relative images with xinclude problem

Post by sorin_ristache »

Yes, other FO processors (for example XEP from RenderX) do not scale the image if you do not request that. You may want to check out Docbench, the bundle of Oxygen + XEP available from RenderX.


Regards,
Sorin
Post Reply