dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post here questions and problems related to editing and publishing DITA content.
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Hello Team,
I wanted some help/information about the the temp folder files that are being generated by dita-ot-1.8.5 version when running our customised XHTML plugin transformation locally using Oxygen Editor.

This use-case is about the insertion of a image into the Topic file which is Authored using Oxygen Editor , but in this case for referring the image name we are using Keyref (Not href) with a unique ID like below way inside the Topic file:
As we are migrating everything with href to be replaced with the keyref for the new oxygen plugin we are developing

<image placement="break" keyref="GUID-7EA66D7E-9077-4834-A35E-46AB4D5450A7" align="left" id="IMAGE_O2Q_1ZY_LRB" scalefit="yes">
<longdescref keyref="GUID-03E8E371-20CA-4CD2-A7FF-6E06886F7053"/>
</image>

Since we are using "keyref" inside the image that we inserted in the above Topic file, they are not getting resolved against the file name which is usually specified inside the href attribute of a keydef which is defined in the "guids.ditamap" like below way for eg:

<keydef keys="GUID-7EA66D7E-B742-4834-A35E-46AB4D5450A7"
href="Autonomous_Data_Guard=GUID-7EA66D7E-B742-4834-A35E-46AB4D5450A7=1.png" format="png"/>

And this guids.ditamap is referred as mapref inside the main ditamap file like below way:
<topicgroup processing-role="resource-only" toc="no">
<topicmeta>
<navtitle>System</navtitle>
</topicmeta>
<mapref href="guids.ditamap" format="ditamap"/>
</topicgroup>


----------------------

Also the temporary generated file for above Topic where I had inserted the image looks like below way, where it has both keyref & href values for image tag alone but not for longdescref:

<image placement="break" keyref="GUID-7EA66D7E-B742-4834-A35E-46AB4D5450A7" align="left"
id="IMAGE_O2Q_1ZY_LRB" scalefit="yes"
ishlabelxpath="./title | @alt | @href | @conref | self::*[@id and not(@varid)]/@id"
ishlinkxpath="@conref | @href[contains(parent::*/@class,' topic/image ') and not(parent::*/@conref)] | @href[contains(parent::*/@class,' topic/longdescref ') and not(parent::*/@conref)] | @href[contains(parent::*/@class,' topic/longquoteref ') and not(parent::*/@conref)]"
ishvarinusexpath="./@varref" ishvarassignedxpath="./@varid" ishtype="ISHIllustration"
class="- topic/image "
xtrf="/Users/koushiktm/Desktop/projects/dita-ot-1.8.5/ditaroot/longdescACMS/xml/About_AuDG=GUID-C57B9A6E-7471-4CDC-8F10-B8386538E31C=3.xml"
xtrc="image:1;26:133"
href="Autonomous_Data_Guard=GUID-7EA66D7E-B742-4834-A35E-46AB4D5450A7=1.png" format="png">
<longdescref keyref="GUID-03E8E371-20CA-4CD2-A7FF-6E06886F7053"
ishlabelxpath="./title | @alt | @href | @conref | self::*[@id and not(@varid)]/@id"
ishlinkxpath="@conref | @href[contains(parent::*/@class,' topic/image ') and not(parent::*/@conref)] | @href[contains(parent::*/@class,' topic/longdescref ') and not(parent::*/@conref)] | @href[contains(parent::*/@class,' topic/longquoteref ') and not(parent::*/@conref)]"
class="- topic/longdescref "
xtrf="/Users/koushiktm/Desktop/projects/dita-ot-1.8.5/ditaroot/longdescACMS/xml/About_AuDG=GUID-C57B9A6E-7471-4CDC-8F10-B8386538E31C=3.xml"
xtrc="longdescref:1;27:72"/>
</image>


Since my XSLT code for XHTML customised plugin looks for href attribute it works fine for the image tag I mentioned above since it has the href attribute for the temp Topic file generated above, it would fail for the longdescref which is again a keyref inside the image tag as mentioned above which usually contains the image descriptions usually.

'longdescrefs' are failing in this case with the below error when running the local transformations ,because XSLT code inside XHTML customised plugin is looking for href attribute and it doesn't find anything inside temp Topic file and fails eventually for longdescrefs but it's not the case with images as it has the href attribute being generated for it inside temp files.
Fatal Error! An empty sequence is not allowed as the value of variable $tempTopic

So if we are able to figure out on how to generate the href attribute for 'longdescref' keyref similar to that of image inside temp Topic file, it would resolve my issue without making any changes to the existing XSLT code from the customised XHTML plugin.


Appreciate your help!


Thanks & Regards,
Koushik
chrispitude
Posts: 710
Joined: Thu May 02, 2019 2:32 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by chrispitude »

Hi Koushik,

I think maybe this is a DITA-OT bug or limitation with <longdescref>. I made a simple testcase with the following topic:

Code: Select all

<topic id="topic">
    <title>My Topic</title>
    <body>
        <image href="image.svg" width="1in">
            <longdescref keyref="topic"/>
        </image>
        <p><xref keyref="topic"/></p>
    </body>
</topic>
The <longdescref> and <xref> both have the same @keyref.

Using ditaot_save_preprocessing.pl, I found that the DITA-OT 3.7.3 in Oxygen v25 also did not consider <longdescref> when resolving @keyref attributes to @href after the keyref preprocessing stage completes:

Code: Select all

      <image href="image.svg" width="1in" placement="inline">
         <longdescref keyref="topic"/>
      </image>
      <p><xref keyref="topic" href="topic.dita"/></p>
Here is the simple testcase:

longdescref_keyref_test.zip
(2.61 KiB) Downloaded 4 times

You might want to file a DITA-OT issue for this so it can be fixed.
Radu
Posts: 8395
Joined: Fri Jul 09, 2004 5:18 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by Radu »

Hi Koushik,

DITA OT 1.8.5 was released 8 years ago and is no longer maintained or supported by us and probably by any other tool or vendor.
As Chris says, the problem can be reproduced also with the latest DITA OT distributions. I added an issue for it here along with a suggested fix:
https://github.com/dita-ot/dita-ot/issues/4071
The DITA OT usually expands keyrefs to hrefs in its Java code so this is not something which is done from XSLT.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Hello chrispitude,

Thank you for your valuable time for this and replying back!

So this below snippet is from the temp folder location after you run the dita-ot transformation locally right:
<image href="image.svg" width="1in" placement="inline">
<longdescref keyref="topic"/>
</image>
<p><xref keyref="topic" href="topic.dita"/></p>

Also one more query here I have is that , who is doing this "keyref preprocessing" is this DITA-OT itself to generate the above code in temp location?


Thanks & Regards,
Koushik
chrispitude
Posts: 710
Joined: Thu May 02, 2019 2:32 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by chrispitude »

Hi Radu,

Using content_model.pl, I ran this command:

Code: Select all

content_model.pl ./plugins/org.oasis-open.dita.v1_3/rng/technicalContent/rng/topic.rng | grep keyref | sed 's/ = .*//'
and I was surprised that almost every element -- even ones like <b> and <tm> -- allows @keyref in its RelaxNG schema definition. But the Oxygen Attributes pane does not show @keyref for all elements. How does Oxygen know which elements realistically support @keyref? I didn't see anything in Oxygen's default DITA cc_config.xml for this.
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Thank you Radu Coravu for your raising the bug to Dita-ot.

I think it answers my questions above, but if at all they are fixing this issue with longdescref they are going to fix this to the latest distributions of DITA-OT right , but not to the version that I'm using in my case: dita-ot-1.8.5 ?

Thanks & Regards,
Koushik
chrispitude
Posts: 710
Joined: Thu May 02, 2019 2:32 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by chrispitude »

Hi Koushik,

That is correct. This would need to be fixed in the Java code, and that is going to be something difficult to do yourself.

If I were you, I suggest (1) adding a comment to Radu's DITA-OT issue to add your support for it, and (2) make long-term plans (if possible) to move to current DITA-OT versions, if possible. But if it were that easy, maybe it would already be done...
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Thank you chrispitude / Radu for all the information you provided.


Regards,
Koushik
Radu
Posts: 8395
Joined: Fri Jul 09, 2004 5:18 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by Radu »

Chris,

Related to:
How does Oxygen know which elements realistically support @keyref?
We show in the Attributes view the "Keys" attribute for an element if the "keys" attribute is defined for that element in the associated DTD/schema/rng, we do not have extra configurations for this.

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

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by Radu »

One possible workaround for Koushik, from what I tested with DITA OT 1.8 during the transformation in the transformation temporary files folder you will find a file named "keydef.xml" which contains mapping from key definitions to references. Maybe using the XSLT customization you have you could use the document() function to load this keydef.xml and use the mappings in it to resolve the keyref value directly in the XSLT code.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
chrispitude
Posts: 710
Joined: Thu May 02, 2019 2:32 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by chrispitude »

Hi Radu,

Ahh, my grep for "keyref" was matching "conkeyref". I needed to grep for "@keyref" instead.

It looks like the list of elements supporting @keyref is

Code: Select all

abbreviated-form
apiname
author
cite
cmdname
coderef
coords
data
data-about
dt
hazardsymbol
image
index-base
index-see
index-see-also
index-sort-as
indexterm
indextermref
keyword
kwd
link
longdescref
longquoteref
lq
mathmlref
menucascade
msgnum
option
param
parmname
ph
pt
publisher
shape
shortcut
source
svgref
term
uicontrol
varname
wintitle
xref
I will make a small testcase, then add it to your DITA-OT issue #4071 for any missing support.
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Hello Radu/Chrispitude,

Maybe using the XSLT customization you have you could use the document() function to load this keydef.xml and use the mappings in it to resolve the keyref value directly in the XSLT code.

I'm trying to implement something like this in XSLT code from above the suggestion from Radu. But I don't know how to read the "keydef.xml" file from the temp directories of dita-ot to load it to document() function in my XSLT code.

Can any of you help me with this approach.


Thanks & Regards,
Koushik
Last edited by koushik9020 on Wed Dec 07, 2022 10:56 am, edited 1 time in total.
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Hello Radu/Chrispitude,
I was able to access the temp folder / results.xml file which has the keydefs I defined for testing purpose inside the xml file using below XSLT template that I created:

<xsl:template match="/">
<xsl:variable name="fi" select="document('../../../temp/Results.xml')" as="document-node()"/>

<xsl:if test="$fi/Report/Doc/keydef/@keys='GUID-FA4256AC-1F78-4F68-AB50-42022A4C6A69'">

<xsl:message>Value of Report is: <xsl:value-of select="$fi/Report/Doc/keydef/@href"/> </xsl:message>

</xsl:if>
</xsl:template>

But not sure how to access the dynamically generated temp folder:temp20221207113856349/keydef.xml file as the temp folder name changes for each run of the transformation.

Please suggest.
Last edited by koushik9020 on Wed Dec 07, 2022 12:46 pm, edited 1 time in total.
Radu
Posts: 8395
Joined: Fri Jul 09, 2004 5:18 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by Radu »

Hi,

The base XSLT stylesheet for XHTML publishing which in my newer DITA OT project is located in "plugins/org.dita.xhtml/xsl/xslhtml/dita2htmlImpl.xsl" defines lots of xsl:param parameters like WORKDIR, you can probably access the values of these parameters if your XSLT stylesheet is a customization stylesheet for the XHTML output.
Also something like:

Code: Select all

<xsl:value-of select="base-uri()"/>
should give you the location of each published XML topic from the temporary files folder.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
koushik9020
Posts: 5
Joined: Tue Dec 06, 2022 11:21 am

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by koushik9020 »

Thank you Radu!!

I was able to fix this using the workaround you suggested to load the 'keydef.xml' file from temp directories in a document function in the XSLT code of our customised plugins which resolved the keyrefs to hrefs for longdescref elements.

Regards,
Koushik
Radu
Posts: 8395
Joined: Fri Jul 09, 2004 5:18 pm

Re: dita-ot-1.8.5 Temp File Attributes when using keyref for image tags

Post by Radu »

Hi Koushik,

Great, I'm glad this works for you.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply