IPublishPostProcessPlugin - DitaDeliveryConvertConditions
Parses XML files and converts InfoShare conditions into conditional elements as required by Dynamic Delivery format.
Plugin Input
Plugin configuration parameters
| Parameter | Required | Default value | Allowed values | Description |
|---|---|---|---|---|
| ObjectTypesToProcess | Yes | page | Which type of objects in the __packages.xml should be parsed to look for conditions. Multiple types need to be separated with ", " (comma+space). | |
| ConvertElementsHavingAttributes | No | ishcondition, data-ishcondition | Valid attribute names | The names of attributes that can contain conditions. |
Input expected in the
context.Items collection
| Item Key | Required | Default value | Item Value Type | Description |
|---|---|---|---|---|
| TransportPackageRootDirectory | Yes | string | The root transport package folder (typically ...\Data\Publish\Data\[RANDOMFOLDERNAME]\work\TP). | |
| ExtendedOverallPackageObjectFilePath | Yes | string | File path of the XML that contains an overview of all the files that need to be transported to Dynamic Delivery (typically full file path to __packages.xml). |
The files that need to be parsed have to be present in the folder provided in the WorkingDirectory property of the context and should contain XML.
Plugin Outcome
Changes made to the file system:
- Every conditional element in parsed files is wrapped into
tcdl:Ifelement. The condition is removed from the original element and placed into theconditionattribute oftcdl:Ifelement. The rest of the attributes and the content are preserved.
Values set in the context as a result: None.
Values set in the context.Items collection as a result: None.
plugin name="ISHDITADELIVERYCONVERTCONDITIONS"example
<plugin name="ISHDITADELIVERYCONVERTCONDITIONS" handler="DitaDeliveryConvertConditions">
<description>Converts remaining conditional attributes to <tcdl:If type="ish:Condition" condition=""> elements</description>
<initialize>
<parameters>
<parameter name="ObjectTypesToProcess">page, toc</parameter>
<parameter name="ConvertElementsHavingAttributes">ishcondition, data-ishcondition</parameter>
</parameters>
</initialize>
</plugin>
Example of converting a page file
Original file:
<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<div class="body">
<div class="section" ishcondition="MODEL=330">...</div>
</div>
</body>
</html>
Converted file:
<?xml version="1.0" encoding="UTF-8"?><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head></head>
<body>
<div class="body">
<tcdl:If type="ish:Condition" condition="(MODEL=330)" xmlns:tcdl="http://www.sdl.com/web/DXA/Format">
<div class="section">...</div>
</tcdl:If>
</div>
</body>
</html>
Plugin flow
The DitaDeliveryConvertConditions does the following:
- Process every file specified in the overall package file provided in the Items collection of the context with the key
ExtendedOverallPackageObjectFilePaththat has type matching the value provided inObjectTypesToProcessparameter. - Find every element that has a conditional attribute specified
ConvertElementsHavingAttributesparameter. - Wrap the element into <tcdl:If type="ish:Condition" condition=""> element.
- Moves the value of the conditional attribute from the original element into the
conditionattribute of the wrapping element.