dita4publishers / org.dita4publishers.html5

Generate complete HTML5-based Web sites from DITA files. Releases are in main dita4publishers project.
11 stars 4 forks source link

graphics not copied #66

Open bcolborn opened 7 years ago

bcolborn commented 7 years ago

With the d4p-html5 plugin (RC26 from Nov 14, 2016) on OT 2.4.5, images aren't copied. fileset/@dir in copy-graphics.xml is empty.

I tried to resolve the issue with Radu's solution from https://github.com/dita4publishers/org.dita4publishers.epub/issues/71 but with no progress. I also tried OT properties like args.input.dir likewise with no progress.

Ultimately I was able to get the images to copy by modifying $absoluteUrl in xsl:template mode="map2graphicmap:handleImageListFile" match="text()" in map2graphicMap.xsl:

     <xsl:variable name="absoluteUrl" as="xs:string"
-      select="relpath:newFile($inputdirUrl, concat(replace($uplevels, '\\', '/'), .))"
+      select="relpath:toUrl(relpath:newFile($inputdir, concat(replace($uplevels, '\\', '/'), .)))"
     />

But even so, results are inconsistent. Some maps get all their images copied, some don't.

bcolborn commented 7 years ago

I've figured out a workaround in two pieces (now with OT 2.5.2).

First, two modifications to the map2graphicmap:handleImageListFile template:

     <xsl:variable name="absoluteUrl" as="xs:string"
-      select="relpath:toUrl(relpath:newFile($inputdir, concat(replace($uplevels, '\\', '/'), .)))" />
+      select="relpath:newFile($inputdirUrl, concat(replace($uplevels, '\\', '/'), .))" />
     <gmap:graphic-map-item id="image-list-item-{$position}" input-url="{$absoluteUrl}"
-      output-url="{relpath:toUrl(relpath:newFile($imagesOutputPath, relpath:getName($absoluteUrl)))}" />
+      output-url="{relpath:toUrl(relpath:newFile($imagesOutputPath, relpath:getName(replace($absoluteUrl, '\\', '/'))))}" />

I really don't see why these changes to $absoluteUrl make a difference because it looks logically equivalent to the original construction. But in the original, the value of $inputdir is missing.

Which brings me to the second part of the workaround. dita.input.dirname has to be specified on the command-line, which I don't think should be required. Furthermore a bogus directory has to be tacked on because the last segment disappears somewhere along the way. If I specify the actual location e.g. C:/users/ben/documents/documentation then it gets truncated to C:/users/ben/documents which is not correct.

So while I'm unblocked I'm not comfortable with the solution and would be interested in something tidier.