Section numbering using xmerl:export
Mikael Karlsson
mikael.karlsson@REDACTED
Thu Aug 29 10:19:40 CEST 2002
Hi,
I am trying to export a Simple Docbook xml to xhtml using
the export function in xmlerl. I wan't to have section numbering
in the 3 top levels and after some testing I could use the
ParentTagPosition from the [{ParentTag, ParentTagPosition}]
argument. (See code below.)
The top section gets position 4, next top section pos 6, subsections
get pos 5, 7, etc.. .
Now, is this just a lucky coincidence or is it something I can
expect for any document?
Thanks
Mikael
..
title(Data, Attrs, [{section,C}, {section,B}, {section,A} | _], E) ->
["<h4>", get_chapter(A,B,C)," ", Data, "</h4>"];
title(Data, Attrs, [{section,B}, {section,A} | _], E) ->
["<h3>", get_chapter(A,B), " ", Data, "</h3>"];
title(Data, Attrs, [{section,A} | _], E) ->
["<h2>",get_chapter(A),". ", Data, "</h2>"];
title(Data, Attrs, [{article,_} | _], E) ->
["<h1>", Data, "</h1>"];
title(Data, Attrs, Parents, E)->
["<h1>", Data, "</h1>"].
get_chapter(A)->
mk_string((A-2) div 2).
get_chapter(A,B) ->
get_chapter(A) ++ "." ++ get_chapter(B-1).
get_chapter(A,B,C) ->
get_chapter(A,B) ++ "." ++ get_chapter(C-1).
More information about the erlang-questions
mailing list