Insert metadata in the <head> for HTML5 files

Post here questions and problems related to editing and publishing DITA content.
gbv34
Posts: 105
Joined: Thu Jan 20, 2022 12:36 pm

Insert metadata in the <head> for HTML5 files

Post by gbv34 »

Hello,

I'm currently in a situation where I notice that metadata declared inn a bookmeta is not propagated into an HTML5 publication, in the <head> element. When publishing my ditamap, I can see it is processed and available in the temp folder.
For instance :

Code: Select all

<copyrfirst>
    <year>2021</year>
</copyrfirst>
is rendered as:

Code: Select all

<copyrfirst class="- topic/data bookmap/copyrfirst " xtrc="copyrfirst:1;10:16"
				xtrf="file:/Users/xxxxxx/0P18U-TEMP-SEN.ditamap">
and the index.html renders this:

Code: Select all

   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta charset="UTF-8">
      <meta name="copyright" content="(C) Copyright 2022">
      <meta name="DC.rights.owner" content="(C) Copyright 2022">
      <meta name="DC.type" content="bookmap">
      <meta name="DC.format" content="HTML5">
      <meta name="DC.identifier" content="guid-e510e093-49cd-4ea5-8c1d-fdc0b0d5c1ea">
      <meta name="DC.language" content="en-us">
      <link rel="stylesheet" type="text/css" href="commonltr.css">
      <title>0P18U-Map</title>
   </head>
Thus, how could I get the previous declaration visible in the <head> element?
------
Gaspard
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Insert metadata in the <head> for HTML5 files

Post by chrispitude »

Hi gbv34,

Can you give me a sample metadata block from one of your books to experiment with?
gbv34
Posts: 105
Joined: Thu Jan 20, 2022 12:36 pm

Re: Insert metadata in the <head> for HTML5 files

Post by gbv34 »

Hi Chris!
Sure. here it is:

Code: Select all

	<bookmeta>
		<bookrights>
			<copyrfirst>
				<year>2021</year>
			</copyrfirst>
			<copyrlast>
				<year/>
			</copyrlast>
			<bookowner>
				<organization/>
			</bookowner>
		</bookrights>
		<pif_content_type value="Product_Status"/>
		<pif_release_type value="dummy-value"/>
		<pif_release_to_sales_date value="10/20/2011 12:00:00 AM"/>
		<pif_part_sample_date value=""/>
		<pif_vintage_year value=""/>
	</bookmeta>
------
Gaspard
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Insert metadata in the <head> for HTML5 files

Post by chrispitude »

Hmm, this might be more work than I thought! From experimentation, I see that <topicmeta> in a <map> cascades down into topics when published, but <bookmeta> in a <bookmap> does not.

The code that propagates metadata from map to topic is in the MoveMetaModule Java module:

https://github.com/dita-ot/dita-ot/blob ... odule.java

but I don't know Java well enough to conclude anything about <bookmeta> versus <topicmeta> from the code.

Another interesting finding is that even with <topicmeta>, the html5 transformation seems to include less metadata in the topics than the xhtml transformation, but I haven't looked into the transformation XSLTs to see if there's some way to configure that.

Here are the metadata cascade rules I found for DITA 1.3:

http://docs.oasis-open.org/dita/dita/v1 ... adata.html

If you publish to XHTML instead of HTML5, do you get anything more useful in the topics from your map?
gbv34
Posts: 105
Joined: Thu Jan 20, 2022 12:36 pm

Re: Insert metadata in the <head> for HTML5 files

Post by gbv34 »

Hi Chris!
Sorry for my late response and thanks a lot for your feedback.
I'm still surprised that out-of-the-box any XHTML output doesn't include in the index.html the metadata declarations made in a topicmeta or bookmeta.
I also noticed this behavior recently with change-histolrylist element and other related elements.

Typically, the following declaration:

Code: Select all

    <bookmeta>
        <critdates>
            <created date="2015-01-01"/>
            <revised modified="2015-02-01"/>
            <revised modified="2015-03-01"/>
            <revised modified="2016-04-01"/>
        </critdates>
        <change-historylist>
            <change-item>
                <change-completed>2015-07-20</change-completed>
                <change-summary>Document title updated from "Widget Repair" to "Widget X2 Repair".</change-summary>
                <data>Product has been updated and the document has been expanded with fresh examples of widget repair.</data>
            </change-item>
            <change-item>
                <change-completed>2013-11-01</change-completed>
                <change-summary>Original document title changed from "Foobar Repair" to "Widget Repair"</change-summary>
                <data>Original product name has been changed, with "Widget" the official product name. Content has also been 
                    updated to include the latest content up to the time of its official release.</data>
            </change-item>
        </change-historylist>
        
    </bookmeta>
only provides this information in the head
image.png
image.png (136.12 KiB) Viewed 602 times
------
Gaspard
Post Reply