Page 1 of 1

DITA Map MS Office Word transformation scenario: resolving xref

Posted: Wed May 22, 2019 12:03 pm
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?

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

Posted: Wed May 22, 2019 2:46 pm
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

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

Posted: Wed May 22, 2019 4:30 pm
by pieterjan_vdw
Thanks Radu. Works like a charm!

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

Posted: Wed Jun 12, 2019 7:48 pm
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>

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

Posted: Thu Jun 13, 2019 8:54 pm
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

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

Posted: Mon Jun 17, 2019 12:36 pm
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.

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

Posted: Tue Jun 18, 2019 2:39 pm
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

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

Posted: Tue Feb 18, 2020 4:45 pm
by Radu
Hi,

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

Regards,
Radu

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

Posted: Fri May 12, 2023 11:49 am
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.

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

Posted: Fri May 12, 2023 1:09 pm
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

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

Posted: Fri May 12, 2023 1:46 pm
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

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

Posted: Fri May 12, 2023 2:07 pm
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