Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation fails with "URI has a fragment component" when calling a <mapref> with a <ditavalref> #3680

Closed
chrispy-snps opened this issue Jan 14, 2021 · 7 comments
Projects
Milestone

Comments

@chrispy-snps
Copy link
Contributor

Expected Behavior

I am trying to use "wrapper maps" to instantiate two different flavors of a shared map:

<!-- bookA.ditamap: -->
<map>
  <ditavalref href="shared/A.ditaval"/>
  <mapref href="shared/shared.ditamap"/>
</map>

<!-- bookB.ditamap: -->
<map>
  <ditavalref href="shared/B.ditaval"/>
  <mapref href="shared/shared.ditamap"/>
</map>

When I transform the bookA and bookB maps, I expect to get the content of shared.ditamap, with the A and B DITAVAL conditions applied respectively.

Actual Behavior

Transformation fails with:

$ dita --input bookA.ditamap --format dita --output A
Reload stale job configuration reference
Error: java.lang.IllegalArgumentException: URI has a fragment component

However, if I filter shared.ditamap using a command line option instead of a wrapper map, then it works:

$ dita --input shared/shared.ditamap --format dita --filter shared/A.ditaval --output A
[normalize] file:/mnt/c/Users/chrispy/Documents/DITA/bugs/shared_maps/A/keys.ditamap
[normalize] file:/mnt/c/Users/chrispy/Documents/DITA/bugs/shared_maps/A/common/common_chapter.dita
[normalize] file:/mnt/c/Users/chrispy/Documents/DITA/bugs/shared_maps/A/shared.ditamap
[normalize] file:/mnt/c/Users/chrispy/Documents/DITA/bugs/shared_maps/A/A/chapter_for_book_a.dita
$

Steps to Reproduce

  1. Unarchive the attached testcase.
  2. Run the two commands shown above.

shared_maps.zip

Environment

  • DITA-OT version: 3.6.0
  • Operating system and version: Ubuntu 18.04 LTS
  • Ran DITA-OT via: dita command
  • Transformation type: dita
@DaveGibbons
Copy link

I'm getting this same error when I have a topicref in a map and the href attribute includes a ? argument, like

1.html?query=2

I've tried it without the = sign, and that doesn't make a difference.

@raducoravu
Copy link
Member

This issue seems to stem from two problems:

  1. The method org.dita.dost.module.BranchFilterModule.filterTopics(Element, List) calls "job.getStore().transform" with an URI which has an anchor component like:

    file:/Users/raducoravu/Downloads/shared_maps/temp/html5/oxygen_dita_temp/shared/common/common_chapter.dita#topic_rrt_vkb_34b

  2. The method org.dita.dost.store.AbstractStore.transform(URI, List) does not expect that the URI passed as a parameter has an anchor component, it appends a ".temp" to it resulting in:

      file:/Users/raducoravu/Downloads/shared_maps/temp/html5/oxygen_dita_temp/shared/common/common_chapter.dita#topic_rrt_vkb_34b.temp
    

and then attempts to create a file for it.

@raducoravu
Copy link
Member

A quick fix could be to suppress the anchor part in "org.dita.dost.module.BranchFilterModule.filterTopics(Element, List)":

         String href = topicref.getAttribute(ATTRIBUTE_NAME_HREF);
    if(href != null && href.contains("#")) {
    	href = href.substring(0, href.indexOf("#"));
    }

But (2) in my opinion should also remove anchor and query parts from the URI before adding that ".temp" suffix to it.

@chrispy-snps
Copy link
Contributor Author

@raducoravu, thanks for looking into this!

Originally I thought this was related specifically to the wrapper map structure. But given your findings, I have confirmed that any use of branch filtering applied to a within-file nested subtopic results in this error.

This means that the problem is more serious than I originally thought.

Our writers use within-file subtopics (instead of the @chunk attribute) to control how content is chunked and presented in online help. We had planned to start using branch filtering in the next few weeks. Unfortunately this bug prevents us from doing so.

@raducoravu
Copy link
Member

@chrispy-snps what I can try to do is to patch things on our side in the DITA OT distribution we ship and I will send you an email once the fix is in place in our nightly builds and you can test it on your side.

@chrispy-snps
Copy link
Contributor Author

@raducoravu - absolutely, I am happy to test!

@raducoravu raducoravu added this to the 3.6.1 milestone Feb 11, 2021
@jelovirt jelovirt added this to To do in 3.6.1 via automation Feb 20, 2021
@jelovirt jelovirt moved this from To do to Done in 3.6.1 Feb 20, 2021
@chrispy-snps
Copy link
Contributor Author

Thanks @raducoravu , @jelovirt !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
3.6.1
Done
Development

No branches or pull requests

4 participants