Documentation Center

IPublishPostProcessPlugin - DitaDeliveryPrepareMetadata

Converts page, binary and publication XML metadata files to JSON format. If no matching XML metadata file is found, a JSON file is created with the publication title. Additionally, the plugin creates JSON schemas with field type information for every converted metadata field.

Plugin Input

Plugin configuration parameters
ParameterRequiredDefault valueAllowed valuesDescription
DITAOTOutDirectoryContextItemKeyYesThe name of key of input parameter to get the full directory name of the out directory generated by DITA-OTThe input value with the full directory name of the out directory generated by DITA-OT will be obtained from the context.Items collection.
PageExtensionsNo.htmlComma separated list of file extensionsThe file extensions that should be treated as page and generate a page_metadata JSON file. Only file extensions containing html with a body element should be in this list.
PageMetadataSchemaFileNameNopage_metadata_schema.jsonValid file name.The file name with the schema with the field type information for the page metadata.
BinaryMetadataSchemaFileNameNobinary_metadata_schema.jsonValid file name.The file name with the schema with the field type information for the binary metadata.
PublicationMetadataSchemaFileNameNopublication_metadata_schema.jsonValid file name.The file name with the schema with the field type information for the publication metadata.
Input expected in the context.Items collection
Item KeyRequiredDefault valueItem Value TypeDescription
MetadataFileExtensionNo.metstringExtension used to find the metadata files in the ExportDirectory that needs to be converted.
The name of key is specified in the parameter DITAOTOutDirectoryContextItemKeyyesstringThe out folder of DITA-OT

Plugin Outcome

Values set in the context.Items collection as a result
Item KeyTypical ValueItem Value TypeDescription
MetadataFileExtension.jsonstringExtension of the converted metadata file.

plugin name="ISHDITADELIVERYPREPAREMETADATA" example


<plugin name="ISHDITADELIVERYPREPAREMETADATA" handler="DitaDeliveryPrepareMetadata">
  <description>
    Collects all files in the DITA-OT "out" folder and tries to find a matching [filenamewithoutextension].met file for them in the input folder.
    When it finds a [filenamewithoutextension].met file, it converts it to a JSON format, adds the title of the publication in 
   "publicationtitle.generated.value" and saves it to the DITA-OT out folder.
    When it does not find a [filenamewithoutextension].met file, it creates a JSON file with the title of the publication in 
   "publicationtitle.generated.value" and saves it to the DITA-OT out folder.
    For the publication it converts the [PublicationGUID].met file to Publication.json.
    This plugin also creates the publication_metadata_schema.json, page_metadata_schema.json, binary_metadata_schema.json for the JSON metadata files.
  </description>
  <initialize>
    <parameters>
      <parameter name="DITAOTOutDirectoryContextItemKey">DITAOTOutDirectory</parameter>
      <parameter name="PublicationMetadataSchemaFileName">publication_metadata_schema.json</parameter>
      <parameter name="PageMetadataSchemaFileName">page_metadata_schema.json</parameter>
      <parameter name="BinaryMetadataSchemaFileName">binary_metadata_schema.json</parameter>
    </parameters>
  </initialize>
</plugin>
		

Example of converted metadata for the page.


{
  "page_meta": {
    "properties": {
      "ishlogicalref.object.id": 6232,
      "ishversionref.object.id": 6233,
      "ishlngref.object.id": 6234,
      "ishref.object.value": "GUID-0EDBAC80-8997-45CA-8578-E8AAB7EE0B6E",
      "ishtype.object.value": "ISHModule",
      "FTITLE.logical.value": "gprs",
      "FDESCRIPTION.logical.value": null,
      "FCHANGES.version.value": "Imported OASIS DITA 1.1",
      "FISHRELEASELABEL.version.value": null,
      "CREATED-ON.lng.value": "2008-10-29T16:10:04Z",
      "FAUTHOR.lng.value": "Author",
      "FSTATUS.lng.value": "Released",
      "MODIFIED-ON.lng.value": "2010-04-09T08:25:36Z",
      "VERSION.version.value": "1",
      "DOC-LANGUAGE.lng.value": [
        "en"
      ],
      "FISHREVCOUNTER.lng.value": 1,
      "ED.lng.value": [
        "GUID-1DD56A41-B68A-419C-8E30-963347845A90"
      ],
      "FUSERGROUP.logical.element": null,
      "READ-ACCESS.logical.element": null,
      "FTESTNUMBER.logical.value": 123,
      "FISHHYPERLINKS.lng.value": [
        "GUID-0F8BA10F-B081-4120-8B32-12736F46B805"
      ],
      "publicationtitle.generated.value": "Users Guide"
    }
  }
}		
			

Example of created metadata for the page.


{
  "page_meta": {
    "properties": {
      "publicationtitle.generated.value": "Users Guide"
    }
  }
}		
			

Example of the page_metadata.schema.json.


{
  "page_meta": {
    "properties": {
      "ishlogicalref.object.id": {
        "type": "integer",
        "searchable": "no"
      },
      "ishversionref.object.id": {
        "type": "integer",
        "searchable": "no"
      },
      "ishlngref.object.id": {
        "type": "integer",
        "searchable": "no"
      },
      "ishref.object.value": {
        "type": "string",
        "searchable": "no"
      },
      "ishtype.object.value": {
        "type": "string",
        "searchable": "no"
      },
      "FTITLE.logical.value": {
        "type": "string",
        "searchable": "no"
      },
      "FDESCRIPTION.logical.value": {
        "type": "string",
        "searchable": "no"
      },
      "FCHANGES.version.value": {
        "type": "string",
        "searchable": "no"
      },
      "FISHRELEASELABEL.version.value": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "searchable": "no"
      },
      "CREATED-ON.lng.value": {
        "type": "date",
        "searchable": "no"
      },
      "FAUTHOR.lng.value": {
        "type": "string",
        "searchable": "no"
      },
      "FSTATUS.lng.value": {
        "type": "string",
        "searchable": "no"
      },
      "MODIFIED-ON.lng.value": {
        "type": "date",
        "searchable": "no"
      },
      "VERSION.version.value": {
        "type": "string",
        "searchable": "no"
      },
      "DOC-LANGUAGE.lng.value": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "searchable": "no"
      },
      "FISHREVCOUNTER.lng.value": {
        "type": "number",
        "searchable": "no"
      },
      "ED.lng.value": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "searchable": "no"
      },
      "FUSERGROUP.logical.element": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "searchable": "no"
      },
      "READ-ACCESS.logical.element": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "searchable": "no"
      },
      "FTESTNUMBER.logical.value": {
        "type": "number",
        "searchable": "no"
      },
      "FISHHYPERLINKS.lng.value": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "searchable": "no"
      },
      "publicationtitle.generated.value": {
        "type": "string",
        "searchable": "no"
      }
    }
  }
}
     

Plugin flow

DitaDeliveryPrepareMetadata does the following:
  • The plugin collects the filenames of every file in the folder provided in the DITAOTOutDirectory item of the context and tries to find a matching [FileNameWithoutExtension.MetadataFileExtension] XML metadata file in the RootWorkDirectory. XML metadata files are recognized by the file extension provided in the MetadataFileExtension parameter (typically.met is used).
    • When a matching metadata file is found:
      • For every metadata file, the file extension of the corresponding content file is compared with the list provided by PageExtensions. If the extension is in the list, the metadata file is converted to a page_metadata JSON, otherwise the metadata file is converted to a binary_metadata JSON.
      • For the supported metadata files it converts the value of every field into JSON format. The name of the JSON property is constructed from the field name, the level and the value type combined, i.e. FTITLE.logical.value. The value of the property is the field value converted to the JSON-friendly format, i.e. 2008-10-29T16:10:04Z.
      • Values for multi-value fields are converted to JSON arrays.
      • For publication metadata, adds the topology URIs in the property topologyuris.generated.value.
      • For publication, binary and page metadata, adds the main map title (or the publication title, if no map title found) in the property publicationtitle.generated.value.
      • The converted files are saved to the folder provided by the item associated with DITAOTOutDirectoryContextItemKey in the context. Metadata files keep the original names but change extension to .json, except the publication metadata file which is saved with the fixed name publication.json.
    • When no matching metadata file is found:
      • If the extension of the file in the RootWorkDirectory is .html, an empty JSON page metadata file is created. Otherwise an empty JSON binary metadata file is created.
      • The main map title is added in the property publicationtitle.generated.value.
      • The created files are saved to the folder provided by the item associated with DITAOTOutDirectoryContextItemKey of the context. Metadata files keep the original names but change extension to .json.
  • Additionally, it creates JSON schemas that contain field metadata (field type, whether the field is multi-value, etc.) for every converted metadata field. The schema files are saved with the names provided in the parameters PageMetadataSchemaFileName, BinaryMetadataSchemaFileName and PublicationMetadataSchemaFileName.