[tex4ht] add metadata to docbook

Radhakrishnan CV cvr at river-valley.org
Wed Apr 3 05:24:15 CEST 2013


On Tue, Apr 2, 2013 at 8:18 PM, Matteo Gamboz <gamboz at medialab.sissa.it>wrote:

> Hi all,
>   I'm trying to add some metadata to a docbook xml.
>
> I'd like to map some simple macros like "\keywords{k}" to xml fragments
> such as:
> <info>
> <keyworsed>
> <keyword>k</keyword
> </keyworsed>
> </info>
>

I would recommend to keep a custom definition for keywords kind of things
and hence \maketitle too in your custom *.cfg since each document class has
its own front matter setup. My bbb.cfg would look like:

%----------- begin bbb.cfg -----------
\makeatletter
\Preamble{xhtml,docbook-mml}

\def\hn{\HCode{\Hnewline}}

\def\maketitle{\IgnorePar\Tg<info>\hn
    \printkeywords
    \Tg</info>\hn
    \ShowPar}

\def\keywords#1{\gdef\@keywords{#1}}%
\let\@keywords\@empty

\def\printkeywords{\ifx\@keywords\@empty\relax\else
   \Tg<keywordset>\hn
   \@for\@kwd:=\@keywords\do
    {\Tg<keyword>\@kwd\Tg</keyword>\hn}
   \Tg</keywordset>\hn
   \fi}

\begin{document}

\EndPreamble

\makeatother

%---------------- end --------------

\printkeywords will parse your comma separated keyword list and tag each
keyword individually.

Your source document will look like:

%-----------------begin x.tex ------------
\documentclass{article}

\begin{document}

\keywords{aa,bb,cc,dd,kkk}

\maketitle

hello

\end{document}

%---------------- end ---------------

The output generated by  the command, htlatex x bbb, will look like:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
    <meta name="generator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
    <meta name="originator" content="TeX4ht (http://www.tug.org/tex4ht/)" />
    <!-- html,xhtml -->
    <meta name="src" content="x.tex" />
    <meta name="date" content="2013-04-03 08:26:00" />
    <link rel="stylesheet" type="text/css" href="x.css" />
  </head>
  <body>
    <info>
      <keywordset>
        <keyword>aa</keyword>
        <keyword>bb</keyword>
        <keyword>cc</keyword>
        <keyword>dd</keyword>
        <keyword>kkk</keyword>
      </keywordset>
    </info>
    <!--l. 11-->
    <p class="indent">hello</p>
  </body>
</html>

Best regards
-- 
Radhakrishnan
River Valley<https://maps.google.com/maps?q=River%20Valley,%20Thiruvananthapuram%20Neyyardam%20Road,%20Kerala,%20India&vector=1>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/tex4ht/attachments/20130403/6be6f6e5/attachment.html>


More information about the tex4ht mailing list