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
386 stars 193 forks source link

Fail to replace temp files on Windows with looping referenced ditamaps #4439

Open demonicjelly opened 2 months ago

demonicjelly commented 2 months ago

Expected Behavior

Successful Run of the dita-ot run

With the following inputs of valid Dita (checked using oxygen XML editor): Within main.dita we reference main2.ditamap

<map>
    <title>Doc</title>
    <topicref href="text.dita">
        <mapref href="main2.ditamap"/>
    </topicref>
</map>

And within main.2 we reference back to main.ditamap

<map>
  <title>Doc2</title>
  <topicgroup id="Map"><keydef href="main.ditamap" keys="main"/></topicgroup>
</map>

This causes the mapref warning type messages related to stylesheet looping and stating Failed to transform document, however should continue to finish the operation and run the normalize steps completing the operation. This has been tested on Mac and succeeds only with the same looping warnings (does not have an issue with the Failing to process copy-in attributes) as shown in the following stack trace

[filter] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/Sample-error/main2.ditamap:6:65: [DOTJ061E][ERROR] Topic reference target is a DITA map but format attribute has not been set. Set format attribute value to "ditamap".
   [mapref] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/Sample-error/main2.ditamap:6:65: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main.ditamap'. 
   [mapref] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/Sample-error/main2.ditamap:6:65: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main.ditamap'. 
   [mapref] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/Sample-error/main.ditamap:7:39: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main2.ditamap'. 
   [mapref] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/Sample-error/main.ditamap:7:39: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main2.ditamap'. 
   [mapref] Too many nested apply-templates calls. The stylesheet may be looping.
   [mapref] Failed to transform document: Failed to transform document: Too many nested apply-templates calls. The stylesheet may be looping.
[normalize] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/out/main2.ditamap
[normalize] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/out/main.ditamap
[normalize] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/out/main.dita
[normalize] file:/Users/dominicj/dev/conversion-qa/conversion-qa-dist-zip/target/DeltaXML-ConversionQA-1_2_0_j/out/text.dita

Actual Behavior

An Error is thrown stating Failed to process copy-to attributes and Failing to delete after copy as can be seen in the stack trace.

Copy of the error message, log file or stack trace

   [filter] file:/C:/DeltaXML/CQA-148/SimpleSample/main2.ditamap:6:65: [DOTJ061E][ERROR] Topic reference target is a DITA map but format attribute has not been set. Set format attribute value to "ditamap".
   [mapref] file:/C:/DeltaXML/CQA-148/SimpleSample/main2.ditamap:6:65: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main.ditamap'.
   [mapref] file:/C:/DeltaXML/CQA-148/SimpleSample/main2.ditamap:6:65: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main.ditamap'.
   [mapref] file:/C:/DeltaXML/CQA-148/SimpleSample/main.ditamap:7:39: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main2.ditamap'.
   [mapref] file:/C:/DeltaXML/CQA-148/SimpleSample/main.ditamap:7:39: [DOTX053E][ERROR]: A element that references another map indirectly includes itself, which results in an infinite loop. The original map reference is to 'main2.ditamap'.
   [mapref] Too many nested apply-templates calls. The stylesheet may be looping.
   [mapref] Failed to transform document: Failed to transform document: Too many nested apply-templates calls. The stylesheet may be looping.
Error: Failed to run pipeline: Failed to process copy-to attributes: Failed to replace file:/C:/Users/SSO-DO~1.JOL/AppData/Local/Temp/2/temp20240318093151511/main.ditamap: Failed to delete original file 'C:\Users\SSO-DO~1.JOL\AppData\Local\Temp\2\temp20240318093151511\main.ditamap.temp' after copy to 'C:\Users\SSO-DO~1.JOL\AppData\Local\Temp\2\temp20240318093151511\main.ditamap'

Steps to Reproduce

  1. Download the following files: SimpleSample.zip

  2. Run the test case: dita-ot-3.7.4\bin\dita --input=SimpleSample\main.ditamap --format=dita -Droot-chunk-override=to-content

Environment

raducoravu commented 2 months ago

Can you also try to download the latest DITA OT 4.2.1 and try the same thing with it? Also what is your use case for attempting to do this? It does not seem to make sense.

demonicjelly commented 2 months ago

This is a simplified example of a set of inputs we've been given. And need to use Java 8 as we are using Dita-OT within some of our software. I put up the use case like this to try simplify it down to the root of the error. Will look into seeing if it is resolved by 4.2.1.