Need to write xsl code in custom header.xml using html5 plugin

95 views
Skip to first unread message

Favorite s

unread,
Jul 5, 2021, 10:34:13 AMJul 5
to DITA-OT Users
We added custom header by adding the below tag in build.xml and it injects the content of header.ml in each html page during compile time which is expected result.

<property name="args.hdr" value=${dita.plugin.com.test.customhtml5.dir}/custom/header.xml"/>

Just we want to show dynamic value of document title/map title(same value in all pages) in all the header. How to write xsl in header.xml. Please help on how we can achieve it ? Thanks in advance.

Kittu Reddy

unread,
Jul 7, 2021, 8:46:26 PMJul 7
to DITA-OT Users
Hi ,

Could you please help on the below request and provide your inputs? 

Thank you in advance.
--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/9a708d03-eafc-4a33-af26-a7149bc01cb2n%40googlegroups.com.

Toshihiko Makita

unread,
Jul 8, 2021, 10:53:17 PMJul 8
to DITA-OT Users
Your requirement is to inset the following contents in the header.

> Just we want to show dynamic value of document title/map title(same value in all pages) in all the header.

This needs the following procedure:
  • Read the ditamap (bookmap or map) and extract the target content.
  • From target content, generate your own header.xml in temporary folder or other location. (Not plug-in folder)
  • Use this header.xml as the value of "args.hdr" property.
However current HTML5 plug-in/plugin.xml does not allow to insert additional build steps in HTML5 build.

So your first work is to make your own (but common to everyone) customization point in HTML5 plug-in and make a pull-request to GitHub DITA-OT project.

Hope this helps your understanding.

Regards,

-- /*------------------------------------------------------------------------------------- 
     Toshihiko Makita 
     Development Group. Antenna House, Inc. Ina Branch
     Web site: http://www.antenna.co.jp/ 
     -------------------------------------------------------------------------------------*/
2021年7月8日木曜日 9:46:26 UTC+9 kittur...@gmail.com:

Toshihiko Makita

unread,
Jul 11, 2021, 5:42:11 PMJul 11
to DITA-OT Users
The pull-request is here:

Add extension point dita.build.html5.after.preprocess to HTML5
2021年7月9日金曜日 11:53:17 UTC+9 Toshihiko Makita:
Message has been deleted

Favorite s

unread,
Jul 14, 2021, 1:12:52 PMJul 14
to DITA-OT Users
Thank You so much for taking out your valuable time.

Saibul Haq

unread,
Jul 17, 2021, 11:58:42 AMJul 17
to DITA-OT Users
@toshihik,

I have the same requirement.

Need to show the keyword value "Full Eligible" or "Minimum Available" text in all the pages in the header based on the include attribute in config.ditaval.

I have two approaches.
1. Plugin to dynamically read the value from keyword ditamap and generate header.xml dynamically. the header will contain the actual value of what we want.
    challenges: didn't know what plugin to generate a file, what plugin to read the document, how to inject other Html elements like logo image in the header.xml
2. Can include the keyword portion in all topics document, so that we can easily get the values using xslt xpath and write in hidden fields in all topic HTML, in the footer.xml we can copy the hidden field value into header section using javascript.
    We are passing ditaval file using --args.filter=c:\dita\ditavals\config.ditaval
   .dita files under c:\dita\dita
   .ditamap files under c:\dita\ditamaps
   In pdf2 plugin, it generates a single document it is easy for us to do xpath query but in html5 it generates each document per topic. 

It would be great if you have any comments.
keydef.ditamap
config.ditaval

Toshihiko Makita

unread,
Jul 18, 2021, 1:55:11 AMJul 18
to DITA-OT Users
> In pdf2 plugin, it generates a single document it is easy for us to do xpath query but in html5 it generates each document per topic. 

The most simple approach is to generate "merged-middle file" from map and topics as PDF plug-in does. 
Once this file generated, you can apply any document level XPath to get the desired content into header/footer XML file.
I will re-implement the pre-processing plug-in and upload it as example.

Regards,

Toshihiko Makita

2021年7月18日日曜日 0:58:42 UTC+9 saibu...@gmail.com:

Toshihiko Makita

unread,
Jul 20, 2021, 8:01:42 PMJul 20
to DITA-OT Users
I updated the plug-in and test results.

plug-in: org.acme.html5.header-2021-07-21.zip

Test result: dita-samples-2021-07-21.zip

2021-07-21.png

Hope this plug-in useful for you.

Regards,

-- 
 /*--------------------------------------------------------------------- 
    Toshihiko Makita
    Development Group.
    Antenna House, Inc. Ina Branch 
    Web site: http://www.antenna.co.jp/ 
                     http://www.antennahouse.com/ 
  --------------------------------------------------------------------*/

2021年7月18日日曜日 14:55:11 UTC+9 Toshihiko Makita:

Saibul Haq

unread,
Jul 25, 2021, 9:34:36 AMJul 25
to DITA-OT Users
Thanks, it works in dita-3.5.2. But in our tool it uses Dita-3.3.2. and it causes the below error message,

command:
dita -i home.ditamap -o out -f mypluginhtml5 --args.input.dir=C:\dita-src

Log:
 [pipeline] Processing C:\Users\KSH2\AppData\Local\Temp\temp20210725212938096\topics\dita1.dita
 [pipeline] TopicMergeModule processing took 787 ms
     [echo] args.hdr=C:\broo\DITA-OT\plugins\com.custom.mypluginhtml5/custom/header.xml
     [echo] args.ftr=C:\broo\DITA-OT\plugins\com.custom.mypluginhtml5/custom/footer.xml
     [xslt] Using class org.apache.tools.ant.taskdefs.optional.TraXLiaison
     [xslt] Processing C:\Users\KSH2\AppData\Local\Temp\temp20210725212938096\dita1_MERGED.xml to C:\Users\ccc\AppData\Local\Temp\temp20210725212938096\custom\custom-header.xml
     [xslt] Loading stylesheet C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-shell.xsl
Apache resolver library found, xml-commons resolver will be used
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-param.xsl:23:64: Fatal Error! XPath syntax error at char 9 on line 23 in {$prmUrl => starts-with}:
     [xslt]     Unexpected token ">" in path expression
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-param.xsl:24:96: Fatal Error! XPath syntax error at char 10 on line 24 in {'file:/' || $}:
     [xslt]     Unexpected token "|" in path expression
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-param.xsl:26:63: Fatal Error! XPath syntax error at char 9 on line 26 in {$prmUrl => starts-with}:
     [xslt]     Unexpected token ">" in path expression
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-param.xsl:27:68: Fatal Error! XPath syntax error at char 9 on line 27 in {$prmUrl => ahf:bsToSlash}:
     [xslt]     Unexpected token ">" in path expression
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-param.xsl:30:102: Fatal Error! XPath syntax error at char 44 on line 30 in {...Url] Invalid file URL=''' |...}:
     [xslt]     Unexpected token "|" in path expression
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-main.xsl:32:218: Fatal Error! XPath syntax error at char 42 on line 32 in {...')]/*[@class => contains-to...}:
     [xslt]     Unexpected token ">" in path expression
     [xslt] C:\broo\DITA-OT\plugins\org.acme.html5.header\xsl\gen-custom-content-main.xsl:34:214: Fatal Error! XPath syntax error at char 42 on line 34 in {...')]/*[@class => contains-to...}:
     [xslt]     Unexpected token ">" in path expression
     [xslt] Failed to process C:\Users\KSH2\AppData\Local\Temp\temp20210725212938096\dita1_MERGED.xml
  [antcall] Exiting C:\broo\DITA-OT\build.xml.
Error: javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 7 errors detected.

Toshihiko Makita

unread,
Jul 25, 2021, 4:47:45 PMJul 25
to DITA-OT Users
I found that bundled Saxon is different between DITA-OT 3.3.2 and 3.5.2.
  • DITA-OT 3.3.2: Saxon-HE-9.9.1-7.jar
  • DITA-OT 3.5.2: Saxon-HE-9.8.0-14.jar
Probably there is XSLT implementation difference between above two versions.
I will test it with DITA-OT 3.3.2.

Regards,

2021年7月25日日曜日 22:34:36 UTC+9 saibu...@gmail.com:

Toshihiko Makita

unread,
Jul 26, 2021, 1:51:54 AMJul 26
to DITA-OT Users
I just uploaded the plug-in once again:


Saxon 9.8 didn't support XSLT 3.0. I downgraded the stylesheet version from 3.0 to 2.0 and modified the codes.
It works fine with DITA-OT 3.3.2 now. 
Also I found that there are lots of HTML5 plug-in differences between 3.3.2 and the newest 3.6.1.
They may be not the fatal difference, but upgrading to use the newest version will be better.

Regards,
-- 
 /*--------------------------------------------------------------------- 
    Toshihiko Makita
    Development Group.
    Antenna House, Inc. Ina Branch 
    Web site: http://www.antenna.co.jp/ 
                     http://www.antennahouse.com/ 
  -----------------------------------------------------------------------*/

2021年7月26日月曜日 5:47:45 UTC+9 Toshihiko Makita:

Saibul Haq

unread,
Jul 26, 2021, 4:05:09 AMJul 26
to DITA-OT Users

Thank you very miuch. I will check and come back on this.

Saibul Haq

unread,
Jul 26, 2021, 9:30:20 AMJul 26
to DITA-OT Users
Hi Toshihiko,
Firstly thanks for all your time and effort to help this. it works as expected.

The only thing is it allows to add in org.dita.html5 plugin, which impacts all the html5 projects.

I am trying to add to a specific custom plugin.


if we add to the specific  info said in the above GitHub URL in our custom html5 plugin(attached) then it throws the below error,
Error: The following error occurred while executing this line:
C:\bro\DITA-OT\plugins\com.custom.html6\build_html6.xml:19: The prefix "dita" for element "dita:extension" is not bound.

I have attached the both OOTB html5 plugin and customized plugin(html6) for your perusal.

Need your comments on how to enable this portion for custom plugins only.
org.dita.html5.zip
com.custom.html6.zip

Toshihiko Makita

unread,
Jul 26, 2021, 8:24:24 PMJul 26
to DITA-OT Users
I could understand your requirement.
  • You don't want to modify base HTML5 plug-in because it affects all of the HTML5 projects.
  • Consequently you made another plug-in named HTML6. The customization for header/footer should implemented only in this plug-in.
I will analyze your plug-in and get back to you.

Regards,

2021年7月26日月曜日 22:30:20 UTC+9 saibu...@gmail.com:

Toshihiko Makita

unread,
Jul 27, 2021, 12:37:34 AMJul 27
to DITA-OT Users
I revised both org.acme.html5.header and com.custom.html6 plugin. It works in DITA-OT 3.3.2 without no problem.


Above contains two plugins. Before running html6 plugin, please execute "./bin/dita --install" command at DITA-OT 3.3.2 folder level command windows.

Also I realized that this HTML5 extension plugin makes it possible to insert custom document level headers/footers in HTML generated Web page. As a result original pull request that adds extension point to HTML5 plugin became useless. I will withdraw this pull-request.

Regards,

Toshihiko Makita



2021年7月27日火曜日 9:24:24 UTC+9 Toshihiko Makita:

Saibul Haq

unread,
Jul 28, 2021, 11:30:04 PMJul 28
to DITA-OT Users
Thank you very much, it worked as expected. really thanks for your time.
Reply all
Reply to author
Forward
0 new messages