Section numbering using xmerl:export
Mikael Karlsson
mikael.karlsson@REDACTED
Thu Aug 29 17:29:07 CEST 2002
Thanks for the reply and code Vlad,
as far as I understand the xmerl:export(Data, Callback) does the similar
as your example, but that instead of a fun you provide a Callback
module which implement every tag you want to transform as a function:
Tag(Data, Attrs, Parents, E)
The Parents argument is a list of: [{ParentTag, ParentTagPosition}]
Empirically I can use the ParentTagPosition to number my section/
subsection titles "on the fly" in one pass as described earlier. The
question is how is the ParentTagPosition to be interpreted? If it is
an implementation dependent feature should it be included in the
arguments to the callback function at all then?
To transform I just scan the xml file and then export it using my callback
module. xmerl is really cool I think:
test() -> {A,_}=xmerl_scan:file(
"/home/mikael/local/src/erlang/erlbook/priv/simpledocbooktest.xml",
[{fetch_fun, fun(DTDSpec,S) -> {ok,S} end}]),
io:fwrite("~s",[xmerl:export(A,sdocbook2xhtml)]).
The only tedious thing is to implement all the Simple DocBook tags (many tags
there are...). Not xmerls fault though :-)
Thanks
Mikael
More information about the erlang-questions
mailing list