On 10/24/2016 02:15 PM, Antti Rauramo wrote:
Hi! We’re using ditac from our CCMS by giving it the map or topic path
as an URL; the URL points to an internal RESTful Web Service that reads
the content from CCMS, eg.

http://localhost/IndoxInternal/IndoxRESTHandler/b3ac11cd-4cea-4128-b104-03e77a0b6cb5/path/to/a/map.ditamap




All hrefs in the documents opened via the Web Service are converted to
absolute URL by prepending the base URI in the same way, up to the GUID
in the example, eg.

http://localhost/IndoxInternal/IndoxRESTHandler/b3ac11cd-4cea-4128-b104-03e77a0b6cb5/path/to/a/media/image.png




All’s well with PDF’s, but now we’re adding webhelp output format, and
images with absolute URLs are not copied to the image directory. After
some research, this appears to be in accordance to the documentation;
ResourceHandler javadocs say “However, a ResourceHandler is invoked only
for resources having an URL which is relative to the document being
preprocessed, not for resource having an absolute URL.”



Does this really mean that if we want to produce a totally stand-alone,
offline webhelp from content that has absolute URL’s, there’s no way to
do that with ditac using parameters, configuration or XSL?

Yes. What you want is not possible out of the box.




Would the
only option be modifying resolveObjectURLs in LoadedDocuments.java?


It's not a good idea to modify such a low-level private final method. Moreover resolveObjectURLs() only applies to <object>s, not to <image>s.

I would do this:

1) Create a subclass of PreProcessor, http://www.xmlmind.com/ditac/_distrib/doc/api/com/xmlmind/ditac/preprocess/PreProcessor.html

2) Change Converter, http://www.xmlmind.com/ditac/_distrib/doc/api/com/xmlmind/ditac/convert/Converter.html ,
to make it invoke your PreProcessor subclass and not the stock PreProcessor.

3) Your PreProcessor subclass should override protected method processImage this way:

---
@Override
protected boolean processImage(Element element, File outDir) {
      element.removeAttributeNS(DITAC_NS_URI, ABSOLUTE_HREF_NAME);
      return super.processImage(element, outDir);
}
---

Yes, the modification consists in just adding *one* line:
---
element.removeAttributeNS(DITAC_NS_URI, ABSOLUTE_HREF_NAME);
---
This line removes the ditac:absoluteHref boolean attribute which is used to mark an href as being initially absolute.

Of course, you could add something slightly more elaborate, that is, remove attribute ditac:absoluteHref only when the image href points outside your CMS.

I assume here that you are using ditac v3. However I'm almost sure that older versions also have a PreProcessor.processImage method.


--
XMLmind DITA Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/ditac-support

Reply via email to