Automatically show audience metadata in a published topic
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 26
- Joined: Mon Mar 11, 2019 11:53 am
Automatically show audience metadata in a published topic
Hi all,
I'm using Oxygen XML 22.1 and WebHelp output. Some of my topics are for administrators only. I want to automatically put a suitable note in each published item of applicable documentation--something like "Audience: Administrators only".
I figure there is a way to extract the value of the audience metadata from a topic's prolog element and combine it with CSS to get what I want. Is this possible and if so, any pointers about where to start?
Thanks,
Dave
I'm using Oxygen XML 22.1 and WebHelp output. Some of my topics are for administrators only. I want to automatically put a suitable note in each published item of applicable documentation--something like "Audience: Administrators only".
I figure there is a way to extract the value of the audience metadata from a topic's prolog element and combine it with CSS to get what I want. Is this possible and if so, any pointers about where to start?
Thanks,
Dave
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Automatically show audience metadata in a published topic
Hello,
WebHelp Responsive allows you to insert custom HTML fragments in the output HTML pages.
Such an HTML fragment can use special Macros that allow you to execute XPath expressions on the input DITA documents (map or topics).
For example:
Considering the following prolog content available in a DITA topic:
You can use the following HTML Fragment:
You can associate the above fragment with the webhelp.fragment.before.body placeholder
Then the HTML output file will contain the following div element as the first child of the body element:
You can contribute a custom CSS file that styles the HTML page content based on the above div.
This way you can display the Audience: Administrators only static content below the topic title:
For the complete example please see the sample Publishing Template available here: https://github.com/oxygenxml/oxygen-pub ... ta-in-body
Regards,
Alin
WebHelp Responsive allows you to insert custom HTML fragments in the output HTML pages.
Such an HTML fragment can use special Macros that allow you to execute XPath expressions on the input DITA documents (map or topics).
For example:
Considering the following prolog content available in a DITA topic:
Code: Select all
<prolog>
<metadata>
<audience audience="administrator"/>
</metadata>
</prolog>
Code: Select all
<div class="audience ${topic-xpath(/topic/prolog/metadata/audience[1]/@audience)}"/>
Then the HTML output file will contain the following div element as the first child of the body element:
Code: Select all
<div class="audience administrator"></div>
This way you can display the Audience: Administrators only static content below the topic title:
Code: Select all
.audience.administrator ~ #wh_topic_container .topictitle1::after{
display: block;
content: "Audience: Administrators only";
font-size: .4em;
font-style: italic;
}
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Mon Mar 11, 2019 11:53 am
Re: Automatically show audience metadata in a published topic
Hi Alin,
One other question--can I show the same metadata content in a concept? I've tried and I can't get this to work for concepts. The fragment I'm using:
The @type attribute of the concept's audience metadata is set correctly. A <div> element for the metadata is inserted into the WebHelp output but it doesn't contain the value set for @type. So it looks like my XPath macro fails to get the metadata or is incorrect.
Do you have any suggestions please? Thanks!
Dave
One other question--can I show the same metadata content in a concept? I've tried and I can't get this to work for concepts. The fragment I'm using:
Code: Select all
<div class="audience ${topic-xpath(/concept/prolog/metadata/audience[1]/@type)}"/>
Do you have any suggestions please? Thanks!
Dave
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Automatically show audience metadata in a published topic
Hi Dave,
Below you can find:
Regards,
Alin
Yes you can show the same metadata in concept topics. I have tested the above fragment using <oXygen/> WebHelp Responsive 23.1 and it worked on my side.davenz wrote: ↑Mon Aug 23, 2021 4:35 pm One other question--can I show the same metadata content in a concept? I've tried and I can't get this to work for concepts. The fragment I'm using:Code: Select all
<div class="audience ${topic-xpath(/concept/prolog/metadata/audience[1]/@type)}"/>
Below you can find:
- The DITA input and the HTML fragment:
- The resulted WebHelp Responsive output:
Code: Select all
/*/prolog/metadata/audience[1]/@type
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 26
- Joined: Mon Mar 11, 2019 11:53 am
Re: Automatically show audience metadata in a published topic
Hi Alin,
A follow-up since last posting this. One topic could have more than one audience element when the content is applicable to more than one audience. For example, administrators and staff could be the audiences for one topic:
In this example, do you have a recommended method please for how to show both labels in the published output of the one document?
And a related question (appreciating that this is a forum for Oxygen XML Editor). We use DITA-OT to also publish HTML5 output in parallel to different systems (Oxygen WebHelp is what we use for a staff intranet). Do you have a suggested starting point for showing the same audience labels in HTML5 output using DITA-OT?
Grateful for any information -- thanks!
Dave
A follow-up since last posting this. One topic could have more than one audience element when the content is applicable to more than one audience. For example, administrators and staff could be the audiences for one topic:
Code: Select all
<prolog>
<metadata>
<audience type="administrator"/>
<audience type="staff"/>
</metadata>
</prolog>
And a related question (appreciating that this is a forum for Oxygen XML Editor). We use DITA-OT to also publish HTML5 output in parallel to different systems (Oxygen WebHelp is what we use for a staff intranet). Do you have a suggested starting point for showing the same audience labels in HTML5 output using DITA-OT?
Grateful for any information -- thanks!
Dave
-
- Site Admin
- Posts: 275
- Joined: Thu Dec 24, 2009 11:21 am
Re: Automatically show audience metadata in a published topic
Hi Dave,
Regards,
Alin
I have adjusted the initial template to handle multiple audience values. You can find it here: https://github.com/oxygenxml/oxygen-pub ... ta-in-bodyOne topic could have more than one audience element when the content is applicable to more than one audience.
Such a customization for the HTML5 output might require a custom DITA-OT extension plugin. You can find more details about how to customize the DITA-OT's generated output in their documentation: https://www.dita-ot.org/dev/topics/custom-plugins.htmlDo you have a suggested starting point for showing the same audience labels in HTML5 output using DITA-OT?
Regards,
Alin
Alin Balasa
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Software Developer
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service