IPublishPostProcessPlugin - IshRemoveXmlAttributes
Parses the published XML files and removes the attributes with the specified names. If the XML file specifies a DTD (either by having a DOCTYPE declaration or an ishdoctype processing instruction), this plugin can also be used to remove the fixed (default) attributes that are defined in the DTD and were persisted into the XML file during the file export phase of the publish.
Plugin Input
| Parameter | Required | Default value | Allowed values | Description |
|---|---|---|---|---|
| RemoveFixedAttributes | No | No | Yes / No | When set to Yes and the file has a DTD, all fixed/default attributes defined in the DTD are removed. |
| RemoveAttributes | No | - | Attribute names | Specifies the names of the attributes to remove (comma-space separated) |
The files that need to be parsed have to be present in the ReportItems collection of the context. Out-of-the-box, the ReportItems collection is created during the file export phase of the publish. Every Topic, Map or Library file present in the ReportItems collection will be parsed.
Plugin Outcome
plugin name="ISHREMOVEXMLATTRIBUTES" example
<plugin name="ISHREMOVEXMLATTRIBUTES" handler="IshRemoveXmlAttributes">
<description>Removes the non-DITA attributes and default attributes defined in the DTD from the XML files</description>
<initialize>
<parameter name="RemoveFixedAttributes">Yes</parameter>
<parameter name="RemoveAttributes">class, ishlabelxpath, ishlinkxpath, ishtype, chg, ishvarinusexpath, ishvarassignedxpath, ishresult,
ishhyperlinkxpath, ishcondition, varid, varref, cid</parameter>
</initialize>
</plugin>
Example of an input XML file
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<!--Arbortext, Inc., 1988-2004, v.4002-->
<?ishdoctype PABpAHMAaABkAG8AYwB0AHkAcABlAD4ADQAKACAAIAA8AGIAYQBzAGUAbgBhAG0AZQA+AHQAbwBwAGkAYwA8AC8AYgBhAHMAZQBuAGEAbQBlAD4ADQA?>
<?ish ishref="GUID-03AB2EA1-F81B-4A22-8149-710094BE1081" version="1" lang="en"?>
<topic id="GUID-03AB2EA1-F81B-4A22-8149-710094BE1081" xml:lang="en" ishlabelxpath="./title"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" ditaarch:DITAArchVersion="1.2"
domains="(topic hi-d) (topic ut-d) (topic indexing-d) (topic hazard-d)" class="- topic/topic ">
<title id="GUID-4E0EC990-B468-401D-9D7B-9B5BEE368FED" ishlabelxpath="./title" class="- topic/title ">Connectors overview</title>
<shortdesc cid="1Qsqmd" ishlabelxpath="./title" class="- topic/shortdesc ">Overview of the different connector possibilities</shortdesc>
<body cid="RYGsg" ishlabelxpath="./title" class="- topic/body ">
<section id="GUID-150A560B-A3B1-43A7-BE5C-F2251CC62CA1" ishcondition="MODEL=330" ishlabelxpath="./title" class="- topic/section ">
<image href="GUID-B6057915-0DE4-45FC-AE28-C910A309EB9C-low.jpg" placement="break" cid="piG4d" ishlabelxpath="./title"
ishvarinusexpath="./@varref" ishvarassignedxpath="./@varid" ishtype="ISHIllustration" class="- topic/image " />
<ol id="GUID-AF0060CD-91E5-40D6-A175-E8ABEBBCBAE2" ishlabelxpath="./title" class="- topic/ol ">
<li cid="b3mOZ" ishlabelxpath="./title" class="- topic/li ">
<indexterm cid="JC7Gx" ishlabelxpath="./title" class="- topic/indexterm ">Connectors<indexterm cid="ACHaw"
ishlabelxpath="./title" class="- topic/indexterm ">Overview</indexterm>
</indexterm>Charger connector<indexterm cid="1swJ6p" ishlabelxpath="./title" class="- topic/indexterm ">Battery charger
<indexterm cid="20BqTT" ishlabelxpath="./title" class="- topic/indexterm ">Connector</indexterm>
</indexterm>
</li>
<li cid="e61xi" ishlabelxpath="./title" class="- topic/li ">Connector for headsets, the connectivity cable and loopset</li>
<li cid="CkVtE" ishlabelxpath="./title" class="- topic/li ">Audio line-in connector for the audio cable to connect the phone
to external audio equipment</li>
</ol>
</section>
</body>
</topic>
Example of a resulting XML file
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<!--Arbortext, Inc., 1988-2004, v.4002-->
<?ishdoctype PABpAHMAaABkAG8AYwB0AHkAcABlAD4ADQAKACAAIAA8AGIAYQBzAGUAbgBhAG0AZQA+AHQAbwBwAGkAYwA8AC8AYgBhAHMAZQBuAGEAbQBlAD4ADQA?>
<?ish ishref="GUID-03AB2EA1-F81B-4A22-8149-710094BE1081" version="1" lang="en"?>
<topic id="GUID-03AB2EA1-F81B-4A22-8149-710094BE1081" xml:lang="en">
<title id="GUID-4E0EC990-B468-401D-9D7B-9B5BEE368FED">Connectors overview</title>
<shortdesc>Overview of the different connector possibilities</shortdesc>
<body>
<section id="GUID-150A560B-A3B1-43A7-BE5C-F2251CC62CA1">
<image href="GUID-B6057915-0DE4-45FC-AE28-C910A309EB9C-low.jpg" placement="break"/>
<ol id="GUID-AF0060CD-91E5-40D6-A175-E8ABEBBCBAE2">
<li>
<indexterm>Connectors<indexterm>Overview</indexterm>
</indexterm>Charger connector<indexterm>Battery charger
<indexterm>Connector</indexterm>
</indexterm>
</li>
<li>Connector for headsets, the connectivity cable and loopset</li>
<li>Audio line-in connector for the audio cable to connect the phone
to external audio equipment</li>
</ol>
</section>
</body>
</topic>
Plugin flow
IshRemoveXmlAttributes does the following:
- If the
RemoveFixedDTDAttributesparameter is set toYes- Opens all Topic, Map or Library files present in the
ReportItemscollection and gathers a list of all the element names per DTD - Per DTD and element name the default attributes are determined
- All Topic, Map or Library files present in the
ReportItemscollection are opened again - All the attributes listed in the parameter
RemoveAttributesare removed and all the attributes that have the same name+value defined in the DTD are removed - The files are saved again with the same name.
- Opens all Topic, Map or Library files present in the
- If the
RemoveFixedDTDAttributesparameter is not set toYes- All Topic, Map or Library files present in the
ReportItemscollection are opened - All the attributes listed in the parameter
RemoveAttributesare removed - The files are saved again with the same name.
- All Topic, Map or Library files present in the