xmerl, ets,(mnisia) Too many db tables

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Mon Oct 10 12:43:01 CEST 2005


Chandru wrote:

> %% This is done in the init function of a gen_server. Create an ETS
> table which xmerl can use.
> ets:new(esaspub_xmerl_rules, [named_table, set, public]).
> 
> %% We also parse the DTD once in the init function.
> catch xmerl_scan:string("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
>  	                             "<!DOCTYPE APITK_Request SYSTEM
> \"http://www.t-mobile.co.uk/dtd/apitk_V1.0.dtd\">\n"
>  	                             "<APITK_Request></APITK_Request>",
>  	                             [{fetch_fun, dtd_fetch_fun()},
>  	                              {rules, esaspub_xmerl_rules}]),
> 
> dtd_fetch_fun() ->
>  	     fun(_, State) ->
>  	             {ok, {string, ?TPG_REQUEST_DTD}, State}
>  	     end.
> 
> And then every time we wanted to parse some XML
> 
> xmerl_scan:string(Xml, [{rules, esaspub_xmerl_rules}, {fetch_fun,
> dtd_fetch_fun(), undefined}])
> 
> That made sure only one ETS table was used. Did you forget about this
> feature Uffe :-)


Well... no, but I had forgotten how easy it was.  ;)

/Uffe



More information about the erlang-questions mailing list