DITA Map MS Office Word transformation scenario: resolving xref

pieterjan_vdw
Posts: 22
Joined: Wed Jun 20, 2018 11:30 am

DITA Map MS Office Word transformation scenario: resolving xref

Post by pieterjan_vdw » Wed May 22, 2019 12:03 pm

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: 6589
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Wed May 22, 2019 2:46 pm

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: 22
Joined: Wed Jun 20, 2018 11:30 am

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

Post by pieterjan_vdw » Wed May 22, 2019 4:30 pm

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

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: 6589
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Thu Jun 13, 2019 8:54 pm

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

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: 6589
Joined: Fri Jul 09, 2004 5:18 pm

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

Post by Radu » Tue Jun 18, 2019 2:39 pm

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

Post Reply