DITA Map MS Office Word transformation scenario: resolving xref

Post here questions and problems related to editing and publishing DITA content.
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

DITA Map MS Office Word transformation scenario: resolving xref

Post by pieterjan_vdw »

The hyperlinks in Word do not work when I publish a bookmap with DITA Map MS Office Word transformation scenario. I get this error message: see Error! Reference source not found.
When I click on the hyperlink in MS Word, there's no link at all.

Below you find my dita content.
I link from one DITA file to another one.

Code: Select all

<p>You then see the <xref href="scherm_standby.dita" class="- topic/xref " format="dita"/> screen.</p>
Do I have to add extra attributes to get this work?
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by Radu »

Hi,

I can reproduce the problem, actually I added an issue for it some time ago:
https://github.com/jelovirt/com.elovirt ... /issues/31

a possible fix you can try on your side, open the XSLT stylesheet OXYGEN_INSTALL_DIR\frameworks\dita\DITA-OT3.x\plugins\com.elovirta.ooxml\docx\word\document.topic.xsl, find the XSLT template:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/topic ')]/
                         *[contains(@class, ' topic/title ')]"
                name="topic.title">
and modify it like this:

Code: Select all

<xsl:template match="*[contains(@class, ' topic/topic ')]/
                         *[contains(@class, ' topic/title ')]"
                name="topic.title">
    <xsl:variable name="depth" select="count(ancestor-or-self::*[contains(@class, ' topic/topic ')])" as="xs:integer"/>
    <w:p>
      <w:pPr>
        <xsl:apply-templates select="." mode="block-style"/>
      </w:pPr>
      <xsl:call-template name="start-bookmark-number">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
      <xsl:call-template name="start-bookmark">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
      <xsl:apply-templates select="." mode="numbering"/>
      <xsl:apply-templates/>
      <xsl:call-template name="end-bookmark">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
      <xsl:call-template name="end-bookmark-number">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
    </w:p>
  </xsl:template>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by pieterjan_vdw »

Thanks Radu. Works like a charm!
gilloxygen
Posts: 6
Joined: Thu Aug 27, 2015 3:11 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by gilloxygen »

Hi, I'm hoping you can help me too as I have the same issue that my xrefs either show as Error! Reference source not found. or as the correct link text but it doesn't take you to the correct location (this depends on whether I select to update the fields when the Word doc opens).
I am on Oxygen 20.1 and have a DITA-OT2.x folder and the code is different in my file so I don't know what I need to change it to:

Code: Select all

  <xsl:template match="*[contains(@class, ' topic/topic ')]" mode="x:toc">
    <xsl:param name="depth" select="count(ancestor-or-self::*[contains(@class, ' topic/topic ')])" as="xs:integer"/>
    <xsl:param name="prefix" as="node()*"/>
    <xsl:variable name="target" select="concat($bookmark-prefix.toc, generate-id())" as="xs:string"/>
    <w:p>
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by Radu »

Hi,

Looking at the XSLT stylesheet:

Oxygen XML Editor/frameworks/dita/DITA-OT2.x/plugins/com.elovirta.ooxml/docx/word/document.topic.xsl

it seems to have that XSLT template I suggested you to change:

Code: Select all

  <xsl:template match="*[contains(@class, ' topic/topic ')]/
                         *[contains(@class, ' topic/title ')]"
                name="topic.title">
and it seems to have a similar content with the one in a DITA OT 3.x distribution.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gilloxygen
Posts: 6
Joined: Thu Aug 27, 2015 3:11 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by gilloxygen »

Hi Radu, I can't get that to correct the issue, I still get the Error! Reference source not found. where the reference should be.
This is what my original file has:

Code: Select all

  <xsl:template match="*[contains(@class, ' topic/topic ')]/
                         *[contains(@class, ' topic/title ')]"
                name="topic.title">
    <xsl:variable name="depth" select="count(ancestor-or-self::*[contains(@class, ' topic/topic ')])" as="xs:integer"/>
    <w:p>
      <w:pPr>
        <xsl:apply-templates select="." mode="block-style"/>
      </w:pPr>
      <xsl:call-template name="start-bookmark">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
      <xsl:apply-templates select="." mode="numbering"/>
      <xsl:apply-templates/>
      <xsl:call-template name="end-bookmark">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
    </w:p>
  </xsl:template>
So your sample also has:

Code: Select all

      <w:pPr>
        <xsl:apply-templates select="." mode="block-style"/>
      </w:pPr>

and:

Code: Select all

      <xsl:call-template name="end-bookmark-number">
        <xsl:with-param name="node" select=".."/>
      </xsl:call-template>
Do you have any other suggestions or is there likely something I've done wrong? I've tried this several times and checked back to ensure I have the correct version active, but get the same result each time.
Thanks.
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by Radu »

Hi,

I'm sorry but it's hard to try and determine what changes took place between two versions of a third party plugin we are bundling. The changes I originally gave should work with the DITA OT 3.x bundled with Oxygen 21.1.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by Radu »

Hi,

We released Oxygen 22 which should have bundled inside its internal DITA OT publishing engine the changes we discussed.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
im_rem
Posts: 20
Joined: Tue Jun 14, 2022 1:08 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by im_rem »

Hello,
the Word/docx output in version 24.1 ignores the section titles inside topics. So they become text with a Standard style in the output. As a result these chapters cannot get crossreferenced either.
I do not know how to handle this in the document.topic.xsl. In the code area regarding DITA sections, [<w:pStyle w:val="Subtitle"/> seems to be applied. But the sections do not even get the Subtitle style, only Standard. Also, I had exptected them to become headings as it is the case in all other transformation types. Could someone know more about this?

Code: Select all

  <xsl:template match="*[contains(@class, ' topic/sectiondiv ')]" name="sectiondiv">
    <xsl:apply-templates select="*"/>
  </xsl:template>

  <xsl:template match="*[contains(@class, ' topic/section ')]" name="section">
    <xsl:apply-templates select="*"/>
  </xsl:template>
  
  <xsl:template match="*[contains(@class, ' topic/section ')]/*[contains(@class, ' topic/title ')] |
                       *[contains(@class, ' topic/example ')]/*[contains(@class, ' topic/title ')]"
                name="section.title">
    <xsl:param name="contents" as="node()*">
      <xsl:apply-templates/>
    </xsl:param>
    <xsl:param name="style">
      <xsl:apply-templates select="." mode="block-style"/>
    </xsl:param>
    <w:p>
      <xsl:if test="exists($style)">
        <w:pPr>
          <xsl:copy-of select="$style"/>
        </w:pPr>  
      </xsl:if>
      <xsl:copy-of select="$contents"/>
    </w:p>
  </xsl:template>
  
  <xsl:template match="*[contains(@class, ' topic/section ')]/*[contains(@class, ' topic/title ')] |
                       *[contains(@class, ' topic/example ')]/*[contains(@class, ' topic/title ')]"
                mode="block-style"
                name="block-style-section.title"
                as="element()*">
    <w:pStyle w:val="Subtitle"/>
  </xsl:template>
Kind regards,
im_rem

PS: I also tried the @chunk="to-content" on the map's root level but it does not make a difference in the Word output.
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by Radu »

Hi,
We (the Oxygen team) are not very familiar with how the DITA to Word publishing plugin works.
If this seems like a bug to you and the bug can be reproduced with the latest plugin contents:
https://github.com/jelovirt/com.elovirta.ooxml/
then maybe you can prepare a very small sample project exhibiting the problem and add an issue for it:
https://github.com/jelovirt/com.elovirta.ooxml/issues
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
im_rem
Posts: 20
Joined: Tue Jun 14, 2022 1:08 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by im_rem »

Radu wrote: Fri May 12, 2023 1:09 pm If this seems like a bug to you and the bug can be reproduced with the latest plugin contents:
https://github.com/jelovirt/com.elovirta.ooxml/
Thank you for the link. I found a corresponding issue in it: https://github.com/jelovirt/com.elovirt ... /issues/63. So I will not create another one.
I will go for a workaround instead by making an HTML5 transformation where the content is chunked into one page. Word can open HTML and save it as DOCX. In a second step, I will only have to find a way to resize all images using a VBA macro. So I will do this now.

Kind regards and have a nice day
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: DITA Map MS Office Word transformation scenario: resolving xref

Post by Radu »

Hi,
Sure, I added a comment on the opened issue with a link to the Oxygen forum. You can also register to watch on the issue to see when it gets fixed.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply