IPublishComparePlugin - IshPublishCompare

Compares 2 publish export XML files and generates a new file with the compared content. This plugin uses the ChangeTracker component which will generate an xml result file with insert and remove processing instructions around the changed, added or removed XML content.

Plugin Input

Plugin configuration parameters
ParameterRequiredDefault valueAllowed valuesDescription
SaveComparedMetadataNoYesBooleanWhether to save a compared metadata file or just a copy of the current version metadata file or compare version metadata file

Plugin Outcome

A file with the XML compare result saved to the provided file path.

Plugin flow

The Publish operation will call the IshPublishCompare for every object that is either in the current version export folder or the compare version export folder.
  • If the object is of type Map, Topic or Library, the CompareXml method is called.
  • If the object is of typeImage or Template, the code of the Publish background task will copy the correct image or template file to the result folder, so the IshPublishCompare is not called for that.
  • If there is a metadata file belonging to the object, the CompareMetadata method is called.
For both the CompareXml or CompareMetadata methods
  • The XmlFileDiff method of the ChangeTracker component is called, which will return whether the file was changed or not and saves the compare result to the given resultsFilePath
  • If the XmlFileDiff method returns that the file was changed and
    • if both the current version file path and compare version file path are filled in, the compare returns PublishCompareResult.Changed
    • only the current version file path is filled in, the compare returns PublishCompareResult.New
    • only the compare version file path is filled in, the compare returns PublishCompareResult.Deleted
  • If the XmlFileDiff method returns that the file was not changed, the compare returns PublishCompareResult.Unchanged

Example of a PublishCompareResult.Changed compare result topic file

<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd"[]>
<?ish ishref="GUID-EDCAD7A5-2B1F-4F35-B324-FB4BB6063617" version="2" lang="en"?>
<topic class="- topic/topic ">
	<title class="- topic/title " id="GUID-7D3B4CD0-9489-41CC-A24D-1EFA429FECDA">Compare and Combine Topic 1</title>
	<shortdesc cid="1bQNDm" class="- topic/shortdesc ">Compare and Combine Topic 1 - Version <?ish text_remove_begin?>1 <?ish text_remove_end?>
		<?ish text_insert_begin?>2 <?ish text_insert_end?>
	</shortdesc>
	<body cid="2II25x" class="- topic/body ">
		<?ish remove_begin?>
		<p cid="DmDU9" class="- topic/p ">
			<?ish text_remove_begin?>Reference to image 1: <?ish text_remove_end?>
			<?ish remove_begin?>
			<image cid="2AgHhL" class="- topic/image " href="GUID-F9B1C417-B6E6-466D-8400-3A441A8410AE-low.v1.png" placement="inline"/>
			<?ish remove_end?>
		</p>
		<?ish remove_end?>
		<?ish insert_begin?>
		<p cid="MrYBO" class="- topic/p ">
			<?ish text_insert_begin?>Reference to image 2: <?ish text_insert_end?>
			<?ish insert_begin?>
			<image cid="ENakr" class="- topic/image " href="GUID-7F85785A-171F-4619-A8BF-4C931AFDA3AD-low.v1.png" placement="inline"/>
			<?ish insert_end?>
		</p>
		<?ish insert_end?>
	</body>
</topic>

Example of a PublishCompareResult.New compare result topic file

<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd"[]>
<?ish ishref="GUID-D67AE806-98A9-4BD3-81C5-5B366ADDC72D" version="1" lang="en"?>
<?ish insert_begin?>
<topic class="- topic/topic ">
	<?ish insert_begin?>
	<title class="- topic/title " id="GUID-308C148B-8ADA-4F56-A79B-0D40CCCFC351" >
		<?ish text_insert_begin?>Compare and Combine Topic 5<?ish text_insert_end?>
	</title>
	<?ish insert_end?>
	<?ish insert_begin?>
	<shortdesc cid="9tqUS" class="- topic/shortdesc ">
		<?ish text_insert_begin?>Compare and Combine Topic 5 short description<?ish text_insert_end?>
	</shortdesc>
	<?ish insert_end?>
	<?ish insert_begin?>
	<body cid="eUJJy" class="- topic/body ">
		<?ish insert_begin?>
		<p cid="zeQdK" class="- topic/p ">
			<?ish text_insert_begin?>Compare and Combine Topic 5 paragraph 1<?ish text_insert_end?>
		</p>
		<?ish insert_end?>
	</body>
	<?ish insert_end?>
</topic>
<?ish insert_end?>

Example of a PublishCompareResult.Deleted compare result topic file

<?xml version="1.0" encoding="UTF-16"?>
<?ish remove_begin?>
<topic class="- topic/topic ">
	<?ish remove_begin?>
	<title class="- topic/title " id="GUID-101DE0AF-3C89-4AFA-89BE-A03F696F2C36">
		<?ish text_remove_begin?>Compare and Combine Topic 4<?ish text_remove_end?>
	</title>
	<?ish remove_end?>
	<?ish remove_begin?>
	<shortdesc cid="6HiHi" class="- topic/shortdesc ">
		<?ish text_remove_begin?>Compare and Combine Topic 4 short description<?ish text_remove_end?>
	</shortdesc>
	<?ish remove_end?>
	<?ish remove_begin?>
	<body cid="1Mn1Df" class="- topic/body ">
		<?ish remove_begin?>
		<p cid="ryczI" class="- topic/p ">
			<?ish text_remove_begin?>Compare and Combine Topic 4 paragraph 1<?ish text_remove_end?>
		</p>
		<?ish remove_end?>
	</body>
	<?ish remove_end?>
</topic>
<?ish remove_end?>

Example of a PublishCompareResult.Changed compare result topic metadata file

<?xml version="1.0" encoding="UTF-16"?>
	 <?xml version="1.0" encoding="utf-16" ?>
<ishobject ishlngref="3110839" ishlogicalref="3110832" ishref="GUID-EDCAD7A5-2B1F-4F35-B324-FB4BB6063617" ishtype="ISHModule" ishversionref="3110837">
	<ishfields>
		<ishfield level="logical" name="FTITLE" xml:space="preserve">Compare and Combine Topic 1</ishfield>
		<ishfield level="logical" name="FDESCRIPTION" xml:space="preserve"/>
		<ishfield level="version" name="VERSION" xml:space="preserve">
			<?ish text_remove_begin?>1 <?ish text_remove_end?>
			<?ish text_insert_begin?>2 <?ish text_insert_end?>
		</ishfield>
		<ishfield level="version" name="FCHANGES" xml:space="preserve">
			<?ish text_remove_begin?>Image 1 referenced <?ish text_remove_end?>
			<?ish text_insert_begin?>Image 2 referenced <?ish text_insert_end?>
		</ishfield>
		<ishfield level="lng" name="CREATED-ON" xml:space="preserve">06/02/2018 <?ish text_remove_begin?>13:54:36 <?ish text_remove_end?>
			<?ish text_insert_begin?>14:02:43 <?ish text_insert_end?>
		</ishfield>
		<ishfield level="lng" name="FAUTHOR" xml:space="preserve">admin</ishfield>
		<ishfield level="lng" name="FSTATUS" xml:space="preserve">Draft</ishfield>
		<ishfield level="lng" name="MODIFIED-ON" xml:space="preserve">08/02/2018 <?ish text_remove_begin?>10:39:58 <?ish text_remove_end?>
			<?ish text_insert_begin?>10:46:46 <?ish text_insert_end?>
		</ishfield>
		<ishfield level="lng" name="DOC-LANGUAGE" xml:space="preserve">en</ishfield>
		<ishfield level="lng" name="FISHREVCOUNTER" xml:space="preserve">3</ishfield>
		<ishfield level="lng" name="ED" xml:space="preserve">
			<?ish text_remove_begin?>GUID-FC531D10-85CA-4A82-BB61-AC1282AECE84 <?ish text_remove_end?>
			<?ish text_insert_begin?>GUID-5CCE0116-BDCE-4251-9377-54270A2DC39D <?ish text_insert_end?>
		</ishfield>
		<ishfield ishvaluetype="element" level="logical" name="FUSERGROUP" xml:space="preserve">VUSERGROUPDEFAULTDEPARTMENT</ishfield>
		<ishfield ishvaluetype="element" level="logical" name="READ-ACCESS" xml:space="preserve"/>
	</ishfields>
</ishobject>