WebHelp XSLT: Display metadata as visible content

Frank Ralf
Posts: 374
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

WebHelp XSLT: Display metadata as visible content

Post by Frank Ralf » Wed Oct 10, 2018 5:15 pm

Hi,

I'm working on a WebHelp extension to display DITA metadata from the new Release Management domain as visible content. I've already had a look at DITA-OT\plugins\org.dita.xhtml\xsl\xslhtml\get-meta.xsl and managed to create templates for new metadata elements from the Release Management domain. However, the current processing flow seems to only create metadata elements in the <head> section of the generated XHTML. How can I create elements in the XHTML <body> instead? Any pointers welcome.

TIA
Frank
Frank Ralf
parson AG
www.parson-europe.com

alin
Site Admin
Posts: 136
Joined: Thu Dec 24, 2009 11:21 am

Re: WebHelp XSLT: Display metadata as visible content

Post by alin » Thu Oct 18, 2018 8:27 am

Hello,

I think that the Publishing Template's macros mechanism might help you. The macros are variables that you can use in the HTML Layout Files (https://www.oxygenxml.com/doc/versions/ ... aid-title4) or in the HTML Fragment Files (https://www.oxygenxml.com/doc/versions/ ... aid-title6). They will be expanded to their corresponding values in the WebHelp Responsive output files at generation time.
The available macros are described here: https://www.oxygenxml.com/doc/versions/ ... aid-title5

You can use the map-xpath or topic-xpath macros to extract metadata from the DITA Map or from the current topic and place it in the final HTML file.
You can have a look at the following Publishing Template Sample from our GitHub Repository: https://github.com/oxygenxml/oxygen-pub ... ith-macros
It uses the map-xpath macro to extract the Copyright metadata from a bookmap and inserts it in the footer section of each HTML output file (see https://github.com/oxygenxml/oxygen-pub ... footer.xml).

For example:

Code: Select all


 <div class="copyright_info">
<span class="copyright_years">
&#xa9;<whc:macro value="${map-xpath(/bookmap/bookmeta/bookrights/copyrfirst/year)}"/>-<whc:macro value="${map-xpath(/bookmap/bookmeta/bookrights/copyrlast/year)}"/>
</span>
<span class="organization">
<whc:macro value="${map-xpath(/bookmap/bookmeta/bookrights/bookowner/organization)}"/>.
</span>
<span> All rights reserved.</span>
</div>

Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com

Frank Ralf
Posts: 374
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: WebHelp XSLT: Display metadata as visible content

Post by Frank Ralf » Tue Oct 30, 2018 3:26 pm

Hi Alin,

Many thanks for this pointer. I wasn't aware of this mechanism. I will give it a try and report back.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com

Frank Ralf
Posts: 374
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: WebHelp XSLT: Display metadata as visible content

Post by Frank Ralf » Tue Oct 30, 2018 8:00 pm

Hi Alin,

The macro mechanism helped indeed with another issue; thanks again.

What I want to do is creating release notes in WebHelp output, similar as https://github.com/doctales/org.doctales.release-notes does for PDF output. However, using the following XSLT variable on the top document level is easier with FO because there is an intermediate large XML file that contains the complete document content. I'm struggling with the problem to find the appropriate extension point for the WebHelp XSLT.

Any pointers welcome.

Best regards,
Frank

Code: Select all


 <!-- The variable change-items contains a list of all change-item elements. -->
<xsl:variable
name="change-items"
select="//*[contains (@class, ' relmgmt-d/change-item ')] "
/>
Frank Ralf
parson AG
www.parson-europe.com

Frank Ralf
Posts: 374
Joined: Thu Jan 23, 2014 2:29 pm
Location: Hamburg
Contact:

Re: WebHelp XSLT: Overriding "macroExpander.xsl"

Post by Frank Ralf » Thu May 16, 2019 2:40 pm

Hi,

We finally managed to extract version-related metadata from maps and topics by overriding com.oxygenxml.webhelp/xsl/macroExpander.xsl and defining the following variable:

Code: Select all

<xsl:variable name="ProductVersion">
    <xsl:choose>
      <xsl:when test="//topicmeta/metadata/prodinfo/vrmlist/vrm">
        <xsl:value-of select="
            //topicmeta/metadata/prodinfo/vrmlist/vrm/
            concat(@version, '.', @release, '.', @modification)" />
      </xsl:when>
      <xsl:when test="//prolog/metadata/prodinfo/vrmlist/vrm">
        <xsl:value-of select="
            //prolog/metadata/prodinfo/vrmlist/vrm/
            concat(@version, '.', @release, '.', @modification)" />
      </xsl:when>
    </xsl:choose>
  </xsl:variable>
  
In most cases this works as expected and we can use this variable to add revision information to the footer of each page of the WebHelp. However, we noticed a strange behavior with certain topics: The above variable isn't set when the topic doesn't contain a <metadata> element even if the version information is correctly pulled from the map for all other topics.

It looks like the behavior is related to the second expression which tests topic metadata:

Code: Select all

 <xsl:when test="//prolog/metadata/prodinfo/vrmlist/vrm">
If I deactivate this second expression in our macroExpander.xsl no version number from the map gets pulled. However, I cannot figure out why this happens and how to avoid it. So any pointers welcome.

Best regards,
Frank
Frank Ralf
parson AG
www.parson-europe.com

Post Reply