dita-ot / dita-ot

DITA Open Toolkit — the open-source publishing engine for content authored in the Darwin Information Typing Architecture.
https://www.dita-ot.org
Apache License 2.0
384 stars 192 forks source link

wrong image output dir if using generate.copy.outer=2 #694

Closed jelovirt closed 12 years ago

jelovirt commented 12 years ago

Converted from SourceForge issue 3402165, submitted by talex24

We use a decentralized DITA setup with main ditamap not in the root directory. Many DITA files have links to images located in the corresponding 'img' subdirectories (see a sample simplified setup below). We have to use the setting generate.copy.outer=2 to generate complete (XHTML) documentation.

PROBLEM: All image links in the resulting HTML files are broken because all image files get copied to directories one level below the intended ones. (So the links in the HTML files are right, but the image files are misplaced). This problem is also reproducible with DITA-OT 1.5.2 and 1.5.3

PROBLEM INVESTIGATION: If using setting generate.copy.outer=2 DITA-OT tries to find out the first common root directory to all involved dirs with DITA files and sets variable $uplevels accordingly (relatively to main ditamap.) All generated file lists (image files also) are addressed relatively to the common root directory. The target for XSLT transformations is then $output.dir/$uplevels. But the target directory for 'copy-image' Ant target in build_preprocess_template.xml is simply $output_dir and this is why image files get copied to wrong locations.

POSSIBLE SOLUTION: The output dir for Ant target 'copy-image' should be ${output.dir}/${uplevels} (We've locally modified the corresponding Ant file and this resolved the issue.)

Diff of original and modified build_preprocess_template.xml: 469c469

<

<copy todir="${output.dir}/${uplevels}">

Sample Setup:

jelovirt commented 12 years ago

Submitted by drmacro

I am seeing this problem as well, namely that the graphics don't go in the right place. However, the proposed patch does not resolve the problem in my case.

In my case, the graphics are below the root map, but the map uses materials from a sibling directory.

In my case, the graphics are in rootdir/topics/graphics.

Without the fix, the graphics are copied to {outdir}/rootdir/topics/graphics but the topics are output to {outdir}/topics, so the graphic references are not correct.

If I add the fix, then the graphics end up going into /rootdir/rootdir/topics/graphics, parallel to the output dir, not under it. (In this case my output dir is under the directory containing the map, but I get the same behavior if I set the output directory to some completely separate location--the graphics are output one level up.

The real issue seems to be not that the graphics are put in the wrong place but that the topic HTML files are not put in the right place--they are output in {outdir}/topics, not {outdir}/rootdir/topics, which would match where the graphics are output without the fix.

The entries in the image.list file are like:

rootdir/topics/graphics/katatedori-shihonage-01.jpg

I'm not sure what the correct fix is, but the proposed patch is not it.

jelovirt commented 12 years ago

Submitted by drmacro

Doing more experiments, it appears that I get this behavior regardless of the setting for generate.file.outer, so maybe something else is going on. This is using 1.5.4M3.

jelovirt commented 12 years ago

Submitted by gladmustang

We will use uplevels to fix image copy issue. For more complicated case Eliot provided, it's tricky to provide a full fix base on current DITA OT design. The work around is to set output folder name is the same as source folder name. With the fix of image copy issue and the workaround provided, Eliot's issue can also be resolved. The fix will be included in DITA OT 1.5.4 M4 build.