Section numbering using xmerl:export

Ulf Wiger <>
Fri Aug 30 10:51:43 CEST 2002


On Fri, 30 Aug 2002, Vlad Dumitrescu wrote:

>>From: "Mikael Karlsson" <>
>>
>>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:
>
>Hi,
>
>I wrote that function just because I thought export wouldn't
>give me what I needed, but it is possible that I didn't dig deep
>enough into xmerl...
>
>I hope Ulf or Richard can confirm if I'm right or wrong: can
>xmerl:export be used to return another XML structure too? The
>examples only return text representing the XML or HTML, so I
>might have been mislead into thinking that this is all
>xmerl:export can do...

Well, it's not that easy, but what you can do is to use the
return value {'#xml-redefine#', NewData} from your callback.
NewData can be a new xmerl structure that replaces the old. Xmerl
will then call the export callbacks with the new structure
instead of the old one. This could of course be used for
re-ordering and such, but I would try not to go overboard with
it.

There is also the {'#xml-alias#', NewTag} that allows for
synonyms, e.g.

section(Data,Attrs,[{section,A},{section,B},{section,C}|_],E) ->
  {'#xml-alias#', h4};
section(Data,Attrs,[{section,A},{section,B}|_],E) ->
  {'#xml-alias#', h3};
section(Data,Attrs,[{section,A}|_],E) ->
  {'#xml-alias#', h2};
section(Data,Attrs,_,E) ->
  {'#xml-alias#', h1}.


/Uffe
-- 
Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson Telecom AB, ATM Multiservice Networks






More information about the erlang-questions mailing list