dita-community / dita13-dita-ot-1.x-support

Plugins that add support for DITA 1.3 vocabularies to the 1.x version of the DITA Open Toolkit.
Apache License 2.0
0 stars 1 forks source link

Mathmlref keyref does not properly work (PDF) #5

Open raducoravu opened 9 years ago

raducoravu commented 9 years ago

My DITA topic has something like:

  <equation-inline>
    <mathml>
      <mathmlref keyref="TST"/>
    </mathml>
  </equation-inline>

and my DITA Map:

<topicref href="topic.dita"/>
<keydef keys="TST" href="test.mml" format="mml" processing-role="resource-only"/>

The PDF does not contain the image (Windows OS). I found two problems so far in the XSLT stylesheet:

          plugins\org.dita-community.dita13.html\xsl\localFunctions.xsl

1) The variable "keydefsURI" needs to be properly converted from file path to URL using "relpath:toUrl":

      <xsl:variable name="keydefsURI" as="xs:string" 
        select="relpath:toUrl(concat($tempdir, '/', 'keydef.xml'))"
      />

2) When the "mappath" variable is used, it needs to be properly converted from file path to URL:

      <xsl:variable name="contextDoc" as="document-node()?"
        select="if (not($format = ('dita', 'ditamap'))) 
        then document(relpath:toUrl($mappath)) 
                   else $keydefDoc"
      />

After making these changes, it works for me.

drmacro commented 9 years ago

I was in the process of implementing these changes when I ran into inconsistent behavior under Windows and got sidetracked trying to understand why it was happening. But these fixes are in progress.

raducoravu commented 9 years ago

One more suggestion to make mathml refs properly work even when the mathml equation is in a folder structure with spaces in it. In the file relpath_util.xsl the function "relpath:toUrl" should be slightly modified like:

        <xsl:function name="relpath:toUrl" as="xs:string">
            <xsl:param name="filepath" as="xs:string"/>
            <xsl:variable name="url" as="xs:string"
                select="if (contains($filepath, '\'))
                then translate($filepath, '\', '/')
                else $filepath
                "
            />
            <xsl:variable name="fileUrl" as="xs:string"
                select="
                if (matches($url, '^[a-zA-Z]:'))
                then concat('file:/', $url)
                else if(starts-with($url, '/')) then concat('file:', $url) else $url"
            />
            <xsl:sequence select="replace($fileUrl, ' ', '%20')"/>
        </xsl:function>

so that it does two extra things:

1) If the initial URL fragment starts with "/", it means it is a Linux file path and we need to prepend file: to it. 2) Replace simple spaces with url encoded version.

This worked for me.