How to set a path for images?

rmcilvride
Posts: 6

How to set a path for images?

Tue Dec 04, 2018 7:54 pm

I am having difficulties getting the img.src.path parameter in my DocBook WebHelp Classic Ant Scenario to work. I need to put all my image files into a single directory, and have all the images in all my books and sets get their images from that directory. Specifically, the image files are located here:

Code: Select all

C:/Activity/Cogent/Docs/DocsOx/Source/Images/
And the book and set source files are here:

Code: Select all

C:/Activity/Cogent/Docs/DocsOx/Source/[document_name]/
My understanding is that I can set the img.src.path to add a prefix to the image name attributes in each <imagedata/> entity in the code. So, as I see it, this scenario:

Scenario 1

Code: Select all

img.src.path = ${cfd}/../Images/
used with

Code: Select all

<imagedata fileref="cdh-prop-butlicenses.gif" align="center"/>
should work the same way as this scenario:

Scenario 2

Code: Select all

img.src.path =
used with

Code: Select all

<imagedata fileref="../Images/cdh-prop-butlicenses.gif" align="center"/>
However, the Scenario 1 yields this output in the HTML:

Code: Select all

<img src="file:///C:/Activity/Cogent/Docs/DocsOx/Source/TestBook1/cdh-prop-butlicenses.gif" align="middle" />
This is not correct. On the other hand, Scenario 2 yields this output in the HTML:

Code: Select all

<img src="images/cdh-prop-butlicenses_530326563.gif" align="middle" />
This is the correct output, as it puts the image where it belongs.

I am using the default Docbook WebHelp Classic transformation scenario; the only edits made were to the img.src.path parameter. In Scenario 1 I have also tried the following:

Code: Select all

img.src.path = ../Images/
img.src.path = ../../../Images/
img.src.path = ${cfd}/../../../Images/
The latter two were tried because the default for the base and output directories are both ${cfd}/out/webhelp/, which is 3 levels down from the Images directory.

I don't know if changing keep.relative.image.uris from 0 to 1 is supposed to have an effect on this behavior, but in any case, it doesn't seem to. The output is the same with either setting.

Interestingly, for generating PDFs from the same source code, this works:

Code: Select all

img.src.path = ../Images/
What am I doing wrong here? How can I get this to work? Thanks for your help on this.
Radu
Posts: 6050

Re: How to set a path for images?

Tue Dec 11, 2018 1:06 pm

Hi,

Sorry for the delay.
The official Docbook documentation for images:

http://www.sagehill.net/docbookxsl/Grap ... tions.html
If the img.src.path parameter is set, its value is prepended to each fileref value if it is not an absolute path. This parameter lets you specify the path to the image files when you build the HTML. If its value is images/ then a fileref value of caution.png is written to the HTML file as src="images/caution.png. But sure to include the trailing slash.
so if you use Oxygen editor variables in its value, then they will get expanded to absolute file paths and then the HTML image will point to the image using these absolute paths which you do not want. For PDF, these absolute paths will not matter because the resulting PDF will include the images inside it anyway but for HTML it does matter.
So for HTML output you will need to specify a relative value for this parameter.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
rmcilvride
Posts: 6

Re: How to set a path for images?

Tue Dec 11, 2018 10:52 pm

Hi Radu,

Thank you for this information. I have tried the following relative paths:

Code: Select all

img.src.path = ../Images/
img.src.path = ../../../Images/
Since the images are here:

Code: Select all

C:/Activity/Cogent/Docs/DocsOx/Source/Images/
And the source files are here:

Code: Select all

C:/Activity/Cogent/Docs/DocsOx/Source/[document_name]/
I would expect the relative path of "../Images/" to find the images, if the path is supposed to be relative to the place where the source files are located.

On the other hand, if the relative path is supposed to be relative to the place where the output is generated, I would expect this path to work: "../../../Images/" because the the output gets generated here:

Code: Select all

C:/Activity/Cogent/Docs/DocsOx/Source/[document_name]/out/webhelp/
(base.dir = ${cfd}/out/webhelp/)
I have also tried these relative paths, just to check:

Code: Select all

img.src.path = ../../Images/
img.src.path = ../../../../Images/
But neither of these work, either. What am I still missing here? Just for your reference, error message I get is:

Code: Select all

java.io.IOException: The filename, directory name, or volume label syntax is incorrect; SystemID: file:/C:/Program%20Files/Oxygen%20XML%20Editor%2020/frameworks/docbook/xsl/com.oxygenxml.webhelp.classic/xsl/docbook/images.xsl; Line#: 45; Column#: 29
Radu
Posts: 6050

Re: How to set a path for images?

Wed Dec 12, 2018 3:34 pm

Hi,

We seem to have some problems in our WebHelp classic output when it comes to handling this parameter, I will add an internal issue for it.
In the meantime, a possible fix:

1) In the XSLT stylesheet OXYGEN_INSTALL_DIR\frameworks\docbook\xsl\com.oxygenxml.webhelp.classic\xsl\docbook\images.xsl comment out this entire XSL template:

Code: Select all

<xsl:template match="@src[parent::xhtml:img]">
...
</xsl:template>
2) In the build file OXYGEN_INSTALL_DIR\frameworks\docbook\xsl\com.oxygenxml.webhelp.classic\build_docbook.xml search for:

Code: Select all

<param name="keep.relative.image.uris" expression="0"/>
and replace with:

Code: Select all

<param name="keep.relative.image.uris" expression="1"/>
3) Set the "img.src.path" parameter to a relative location like "../" and then publish.

You will need to manually copy the images folder in the proper location next to the output folder but at least the image paths will remain relative and prefixed with "../".

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
rmcilvride
Posts: 6

Re: How to set a path for images?

Fri Dec 14, 2018 1:10 am

Hi Radu,

Thank you for these suggestions. I followed these steps, and got it to work, but I was unable to set a path to my Images directory, like: "../../../Images", because as I understand it, that is not considered a relative path. Moving the images to the same directory as my source files, and using "../../" to move up two levels from the "out/webhelp/" output directory did work.

However, putting the images with the XML source files is inconvenient, since we have multiple source file directories, one for each book and one for each set, and many of the books share images. This means creating and maintaining multiple copies of our images.

For now, I will change the imagedata fileref attribute on each source code file from this:

Code: Select all

<imagedata fileref="myimage.gif"/>
to this:

Code: Select all

<imagedata fileref="../Images/myimage.gif"/>
This is not an ideal solution, but it will at least allow us to keep a single copy of all images. When do you expect to have a release of oXygen in which the WebHelp Classic output mechanism is fixed?

Best regards,

Bob
Radu
Posts: 6050

Re: How to set a path for images?

Fri Dec 14, 2018 10:13 am

Hi Bob,

Unfortunately I cannot give you an estimate for when the DocBook WebHelp classic publishing will be fixed to support "img.src.path" in exactly the same way in which it supports the same parameter for XHTML based outputs. But when we do, we'll update this forum thread.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “DocBook”

Who is online

Users browsing this forum: No registered users and 1 guest