Documentation Center

IPublishPostProcessPlugin - DitaDeliveryConvertToc

Parses the Table Of Contents HTML file produced by DITA-OT and converts it to a TOC XML file that complies with the format needed for Dynamic Delivery.

Plugin Input

Plugin configuration parameters
ParameterRequiredDefault valueAllowed valuesDescription
ObjectTypesToProcessYesbinary, page, binary_schema, toc, publication, publication_schema, page_schema, indexWhich type of objects in the __packages.xml should be parsed to look for file references. Multiple types need to be separated with ", " (comma+space).
Input expected in the context.Items collection
Item KeyRequiredDefault valueItem Value TypeDescription
TransportPackageRootDirectoryYesstringThe root transport package folder (typically ...\Data\Publish\Data\[RANDOMFOLDERNAME]\work\TP)
ExtendedOverallPackageObjectFilePathYesstringFile path of the XML that contains an overview of all the files that need to be transported to Dynamic Delivery.
TransportPackageDirectoriesYesList<string>A list of Folder paths were the Transport Packages content that needs to be sent can be found. When this plugin has completed its process, the list only contains one value: The location of the ALL folder.

The files that need to be parsed have to be present in the folder provided in the RootWorkDirectory property of the context and should contain XML.

Plugin Outcome

Changes made to the file system:
  • All files that correspond to an Object with a Type that is present in ObjectTypesToProcess in the __packages.xml will be parsed and converted to XML.
    • For example: The file ish:[PUBLICATIONOUTPUTID]-1-512.html of type="toc" which will be converted to ish:[PUBLICATIONOUTPUTID]-1-512.xml.
  • The package.xml file is re-created in the TP\ALL folder, as the TOC filename changed. That file contains a list of all the files that need to be sent.
  • A __packages.xml file is re-created in the TP folder, as the TOC filename changed. This file is similar to the package.xml, but holds some extra information of the files to send.
Values set in the context as a result
Context PropertiesTypical ValueDescription
RootDocumentObjectFile...\Data\Publish\Data\[RANDOMFOLDERNAME]\work\[VERSION]\[LANGUAGE]\[GUID].ditamapFile path of the root document with the original filename (before the conversion).

Values set in the context.Items collection as a result: None

plugin name="ISHDITADELIVERYCONVERTTOC" example


<plugin name="ISHDITADELIVERYCONVERTTOC" handler="DitaDeliveryConvertToc">
  <description>
     Parses files of type "toc" in the "TP\ALL" folder, and converts them from HTML produced by DITA-OT to XML 
     that complies with the format needed for Dynamic Delivery
  </description>
  <initialize>
    <parameters>
      <parameter name="ObjectTypesToProcess">toc</parameter>              
    </parameters>
  </initialize>
</plugin>

Example of an input TOC html file as created by DITA-OT


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">   
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />           
    <meta name="copyright" content="(C) Copyright 2016" />      
    <meta name="DC.rights.owner" content="(C) Copyright 2016" />      
    <meta name="DC.Type" content="map" />      
    <meta name="DC.Format" content="XHTML" />      
    <meta name="DC.Identifier" content="GUID-C9CA7357-CBA3-43B3-A4B2-B977AD1B7D1E" />      
    <meta name="DC.Language" content="en" />      
    <link rel="stylesheet" type="text/css" href="commonltr.css" />      
    <title>User Guide</title>
  </head>   
  <body id="GUID-C9CA7357-CBA3-43B3-A4B2-B977AD1B7D1E">
    <h1 class="title topictitle1">User Guide</h1>
    <div>
      <ul xml:lang="en" lang="en" class="map">
        <naventry class="topicref" ref="ish:1420746-164223-16">
          <title>Dear Customer</title>
        </naventry>
        <naventry class="topicref" ref="ish:1420746-164247-16#GUID-53925A2B-DCEE-48DB-BB47-623F13EA618F">
          <title>For your safety</title>
        </naventry>
        <naventry class="topicref" ref="ish:1420746-164231-16">
          <title>Your phone</title>
          <naventry class="topicref" ref="ish:1420746-164187-16">
            <title>Standby mode</title>
          </naventry>
          <naventry class="topicref" ref="ish:1420746-164255-16#GUID-87DD5F98-0359-4975-BBA2-3B494D82BE3C">
            <title>Essential indicators in standby mode</title>
          </naventry>
        </naventry>
      </ul>
    </div>
  </body>
</html>

Example of an output xml file


<?xml version="1.0" encoding="utf-8"?>
<navroot id="ish:1420746-1-512" version="1.0" xmlns:tcdl="http://www.sdl.com/web/DXA/Format">
  <title>User Guide</title>
  <naventry ref="ish:1420746-164223-16" id="ish:1420746-2-1024">
    <title>Dear Customer</title>
  </naventry>
  <naventry ref="ish:1420746-164247-16" addanchor="GUID-53925A2B-DCEE-48DB-BB47-623F13EA618F" id="ish:1420746-3-1024">
    <title>For your safety</title>
  </naventry>
  <naventry ref="ish:1420746-164231-16" id="ish:1420746-4-1024">
    <title>Your phone</title>
    <naventry ref="ish:1420746-164187-16" id="ish:1420746-5-1024">
      <title>Standby mode</title>
    </naventry>
    <naventry ref="ish:1420746-164255-16" addanchor="GUID-87DD5F98-0359-4975-BBA2-3B494D82BE3C" id="ish:1420746-6-1024">
      <title>Essential indicators in standby mode</title>
    </naventry>
  </naventry>
</navroot>

Plugin flow

DitaDeliveryConvertToc does the following:
  • The plugin first builds a list with all the Content attributes of all the Object entries in the __packages.xml file. That file is provided in the ExtendedOverallPackageObjectFilePath property of the context that matches one of the types configured in the ObjectTypesToProcess parameter.
  • Every file in the list that matches the given ObjectTypesToProcess is loaded as XML in memory, parsed, and only the XML content of the following element names generates output: body, h1, naventry, title, or any element in the title.
  • The following output is generated:
    • When the element is body, a navroot element is generated with an id and a version attribute.
    • When the element is h1, a title element is generated and all the content of the title is copied.
    • When the element is naventry, a naventry element is generated with the ref, (an optional addanchor attribute if the href contains a #ELEMENTID part) and conditional attributes and a unique id attribute is added.
    • When the element is title, a title element is generated and all the content of the title is copied.
  • Eventually the changed file content is saved to the same file name.
  • The values of the context that need to be changed are set.