IPublishPostProcessPlugin - IshRemoveNotLockedNavTitles
Removes the navtitle elements and attributes from topicref elements (or specializations of the topicref element) that do not have the locktitle attributes set to yes from DITA maps (or specializations of DITA maps), to avoid that DITA-OT takes them into account.
Plugin Input
Plugin configuration parameters: None
Input expected in the context.Items collection: None
The files that need to be parsed have to be present in the folder provided in the RootWorkDirectory property of the context and should have the ditamap file extension. If there are no files with a ditamap extension found, the files having an xml file extension with a matching file with a met extension that identifies the file as being a map are processed as well. The class attribute needs to be present in the file or in the DTD referenced in the ditamap file.
Plugin Outcome
navtitle elements and attributes that do not have the locktitle attributes in every file with the ditamap file extension are removed and the file is saved again with the same filename.
Values set in the context as a result: None.
Values set in the context.Items collection as a result: None.
plugin name="ISHREMOVENOTLOCKEDNAVTITLES" example
<plugin name="ISHREMOVENOTLOCKEDNAVTITLES" handler="IshRemoveNotLockedNavTitles">
<description>Removes the "navtitle" elements and attributes from "topicref" elements (or specializations of the
"topicref" element) that do not have the "locktitle" attributes set to "yes" from DITA maps (or specializations
of DITA maps), to avoid that "DITA-OT" takes them into account.
</description>
<initialize/>
</plugin>
Example of an input ditamap file
<?xml version="1.0" encoding="UTF-16"?>
<?ish ishref="GUID-948607D2-1F33-43B4-B145-0E19594AA808" version="1" lang="en"?>
<bookmap id="GUID-948607D2-1F33-43B4-B145-0E19594AA808" xml:lang="en class="- map/map bookmap/bookmap ">
<title id="GUID-ED6EAB92-84A4-43DB-8F9A-63D16861A045" class="- topic/title ">BookMap The Smurfs 2</title>
<chapter navtitle="title1" href="GUID-5293EEA6-6DAF-407E-924A-D9F810B396C9.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Introduction The Smurfs</navtitle>
</topicmeta>
</chapter>
<chapter locktitle="yes" href="GUID-3560EB2C-207B-4C08-94F1-08B815DFCF85.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Peyo</navtitle>
</topicmeta>
</chapter>
<chapter locktitle="yes" href="GUID-B1B33A17-3522-498D-B4F4-CFAA7032F9EF.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Johan et Piwit</navtitle>
</topicmeta>
<topicref navtitle="title4" href="GUID-B1B33A17-3522-498D-B4F4-CFAA7032F9EF.xml" class="- map/topicref ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Johan et Piwit2</navtitle>
</topicmeta>
</topicref>
</chapter>
<chapter navtitle="title5" href="GUID-31AD7404-DB60-484D-9EC7-D039C6A25C44.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Smurf Universe</navtitle>
</topicmeta>
<topicref href="GUID-31AD7404-DB60-484D-9EC7-D039C6A25C44.xml" class="- map/topicref ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Smurf Universe2</navtitle>
</topicmeta>
</topicref>
</chapter>
</bookmap>
Example of a resulting ditamap file
<?xml version="1.0" encoding="UTF-16"?>
<?ish ishref="GUID-948607D2-1F33-43B4-B145-0E19594AA808" version="1" lang="en"?>
<bookmap id="GUID-948607D2-1F33-43B4-B145-0E19594AA808" xml:lang="en class="- map/map bookmap/bookmap ">
<title id="GUID-ED6EAB92-84A4-43DB-8F9A-63D16861A045" class="- topic/title ">BookMap The Smurfs 2</title>
<chapter href="GUID-5293EEA6-6DAF-407E-924A-D9F810B396C9.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
</topicmeta>
</chapter>
<chapter locktitle="yes" href="GUID-3560EB2C-207B-4C08-94F1-08B815DFCF85.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Peyo</navtitle>
</topicmeta>
</chapter>
<chapter locktitle="yes" href="GUID-B1B33A17-3522-498D-B4F4-CFAA7032F9EF.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
<navtitle class="- topic/navtitle ">Johan et Piwit</navtitle>
</topicmeta>
<topicref href="GUID-B1B33A17-3522-498D-B4F4-CFAA7032F9EF.xml" class="- map/topicref ">
<topicmeta class="- map/topicmeta ">
</topicmeta>
</topicref>
</chapter>
<chapter href="GUID-31AD7404-DB60-484D-9EC7-D039C6A25C44.xml" class="- map/topicref bookmap/chapter ">
<topicmeta class="- map/topicmeta ">
</topicmeta>
<topicref href="GUID-31AD7404-DB60-484D-9EC7-D039C6A25C44.xml" class="- map/topicref ">
<topicmeta class="- map/topicmeta ">
</topicmeta>
</topicref>
</chapter>
</bookmap>
Plugin flow
IshRemoveNotLockedNavTitles does the following:
- Opens all files with the
ditamapextension and searches fortopicrefelements or their specializations which do not have thelocktitleattribute set toyesand removes thenavtitleif:- The reference contains an
hreforkeyrefattribute - The reference contains a target with
local scope(so an ID in the repository) - The element is no specialization of the DITA
topicheadortopicgroupelements
- The reference contains an
- If there are no files with a ditamap extension found in the previous part, the files having an
xmlfile extension with a matching file with ametextension that identifies the file as being amapare processed as well, and the samenavtitleremoval rules as above are applied. - Eventually the changed file content is saved to the same file name with a
UTF-16encoding.