Highlighted

AEM XML Documentation Plugin-Customize the bookmap metadata elements

meghanap4604265

21-07-2020

Hello Team,

 

I am currently working on how to customize bookmap metadata elements using AEM, I am trying to append/insert user given template form data to book map metadata elements eg:<bookpartno>MN-1234-56</bookpartno> etc.

 

Please find the below mentioned requirement and the image file for better understanding of the use case:

 

Existing functionality : In the Assets Console,Whenever an author creates a DITA Topic or Map using the OOTB DITA templates,the user given template form value of Title field,gets automatically inserted to the <title></title>tag and the title is rendered on the web editor.

 

Analysis on OOTB Functionality,from where this title is being fetched:The value of the title attribute is getting saved in the XML original rendition when the asset is created for the very first time and is always being read from there, the xml original rendition like [1]

 

Below is the analysis on the backend process that happens while creating DITA bookmap i.e: Assets console>Files>Create>DITA Map>bookmap

At save or creation of the bookmap a POST request like [2] is triggered with operation 'createditamap' which is handled by a servlet [3] which reads all the data values (specifically reads the title) and sets all the properties at the node and in the XML original rendition.

[1] /content/dam/techpubs/en/test-content/maps/test-bookmap.ditamap/jcr:content/renditions/original/jcr:content

[2] /bin/referencelistener

[3] com/adobe/fmdita/versioncontrol/VersionUtils.java

 

Current Requirement/Customization: Existing bookmap template has two fields i.e: Title and Name.Now,there is a requirement to add few fields in bookmap template like Short description, Document Type,Product Name,Version,Part Number,Revision and capture the authored template form data and insert the corresponding values in the bookmap metadata elements like <shortdesc>,<category>,<prodname>,<vrm>,<bookpartno>,<volume> respectively.

 

Use case: Business team would like to make use of this inserted values of bookmap metadata elements and print the book map metadata info on the PDF Front cover.

 

Approach I tried to achieve this :

1)I had customized the bookmap template by adding above mentioned template fields.I had overlaid it to the /apps,path in crxde lite:/apps/fmdita/ditamapeditor/core/createditamap/jcr:content/body/content/items/properties/items/container/items/form

2) I had overlaid the existing servlet class called VersionUtils.java ,I am able to capture the user given information i.e I am able to retrieve the data using SlingHttpServletRequest request object.I am able to save the user given template data under jcr:content node of a ditamap (/content/dam/techpubs/en/test-content/maps/test-descritpion.ditamap/jcr:content).I am trying to input the information into the XML original rendition file,like the existing <title></title> works.

 

Challenge: I tried to debug how the <title> tag is being formed in the rendition file.I believe there is a query which gets the <title> tag and append it to the file.

 

I need info on how below query works and how to form other tags like <prodinfo>,<bookpartno> etc into the rendition file,the way <title> is being formed.

Below is the code snippet for Dita query from OOTB VersionUtils.java class (com.adobe.fmdita.versioncontrol.VersionUtils)

 

DitaDoc ditadoc = new DitaDoc(session.getNode(newTopicPath));NodeList nodeList = (NodeList)ditadoc.query("/*[contains(@class, 'map/map')]/*[contains(@class, 'topic/title') and not(contains(@class, 'bookmap/booktitle'))]", XPathConstants.NODESET);if (nodeList.getLength() == 0) nodeList = (NodeList)ditadoc.query("/*[contains(@class, 'bookmap/bookmap')]/*[contains(@class, 'bookmap/booktitle')]/*[contains(@class, 'bookmap/mainbooktitle')]", XPathConstants.NODESET);if (nodeList.getLength() == 0) throw new Exception("No title element found in the template");

 

Below is the sample code snippet of original rendition file,which stores the title value of the bookmap:

location of  the file:(/content/dam/techpubs/en/test-content/maps/test-bookmap.ditamap/jcr:content/renditions/original)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap/dtd/bookmap.dtd">
<bookmap id="bookmap.ditamap_769f911e-da18-412e-a4fe-e6e2f4bdc0c9">
<title>test bookmap</title>
</bookmap>

 

screen2 (1).PNG

 

Can anyone help me with this?Any help would be greatly appreciated.

Replies