Add metadata from DITA map to menu items in HTML output

tonra
Posts: 7
Joined: Wed Jun 05, 2019 10:39 am
Location: Germany

Add metadata from DITA map to menu items in HTML output

Post by tonra » Thu Aug 15, 2019 12:18 pm

Hi,

I have an XSLT-related question regarding the Oxygen WebHelp Responsive transformation.
I would like to get metadata from a DITA map and integrate it to the side toc navigation's elements (as an attribute).
The HTML part of this has to be done in sidetoc.xsl, I guess. But how can I get the data from the <audience> element in <topicmeta>? Unfortunately, I am not that familiar to XSLT/XPath so that I don't know how to access the DITA map from sidetoc.xsl or tocDitaImpl.xsl. I tried to use the integration of the <shortdesc> element as an example but had no success yet.

Would it also be possible to access the <audience> element in the DITA map from topic.xsl?

Thanks a lot in advance!

Best regards,
Anton

tonra
Posts: 7
Joined: Wed Jun 05, 2019 10:39 am
Location: Germany

Re: Add metadata from DITA map to menu items in HTML output

Post by tonra » Fri Aug 16, 2019 3:10 pm

Hi,

I managed to get the desired metadata. It was a bit tricky to understand the XPath syntax using variables.
This is my approach:

Code: Select all

<xsl:value-of select="toc:topicmeta/toc:audience/@type"/>
(within the xsl template matching xsl:topic).

Unfortunately, there is a problem when I try to get only the metadata from topics at a deeper level. Here is an example:

Code: Select all

<map>
<title></title>
<topicref>
	<topicmeta><audience type="novice"/></topicmeta>
	<topicref>
		<topicmeta><audience type="expert"/></topicmeta>
	</topicref>
</topicref>
</map>
With the XPath command

Code: Select all

map/topicref/topicref/topicmeta/audience/@type
it is possible to get the desired result, namely "expert".

When I try to achieve the same within sidetoc.xsl with

Code: Select all

//toc:toc/toc:topic/toc:topic/toc:topicmeta/toc:audience/@type
I get the @type values from parents and siblings, too. What am I doing wrong?

Best regards,
Anton

Post Reply