Erlsom question, erlsom:scan fails but erlsom:scan_file ok

Russell Brown russell.brown@REDACTED
Wed Aug 19 15:27:03 CEST 2009


Hi,
I hope it is OK posting this here. I tried looking at the erlsom  
support forum on Sourceforge and the last post was 2008 so I figured  
it was all but dead (or maybe perfect software, who knows?)

I am using erlsom for an EC2 client I am writing. I created an XSD  
(munged from AWS wsdl file) and got erlsom to "compile" it to a model.  
I then use the Model to scan the result of an http call to an EC2  
webservice. I get this:


** exception throw: {'EXIT',
                      {error,
                       [{exception,
                         {function_clause,
                          [{erlsom_parse,stateMachine,
                            [startDocument,
                             {state,undefined,undefined,
                              {ok,
                               {model,
                                [{type,'_document',sequence,[{...}], 
[],...},
                                 {type,'_document- 
UnmonitorInstancesResponse',
                                  sequence,
                                  [...],...},
                                 {type,'_document- 
MonitorInstancesResponse',
                                  sequence,...},
                                 {type,'_document- 
UnmonitorInstances',...},
                                 {type,...},
                                 {...}|...],
                                [{ns,
                                  "http://ec2.amazonaws.com/doc/2009-04-04/ 
",
                                  undefined},
                                 {ns,"http://www.w3.org/2001/ 
XMLSchema",[...]}],
                                "http://ec2.amazonaws.com/doc/2009-04-04/ 
",[]}},
                              [],undefined,undefined}]},
                           {erlsom_parse,xml2StructCallback,2},
                           {erlsom_sax_list,wrapCallback,2},
                           {erlsom_sax_list,parse,2},
                           {erlsom,scan2,3},
                           {erl_eval,do_apply,5},
                           {shell,exprs,6},
                           {shell,eval_exprs,6}]}},
                        {stack,[undefined]},
                        {received,startDocument}]}}
      in function  erlsom:scan2/3


The parameters to the function being the Model returned from {ok,  
Model} = erlsom:compile_xsd_file("ec2.xsd") and  Body from {ok,  
{{_Version, 200, _ReasonPhrase}, _Headers, Body}} = http:request( Url ),

However if I write the Body to a file with  
file:write_file("response.xml", Body) and then call  
erlsom:scan_file("response.xml", Model). it works as I would expect  
and as described in the documentation.

what happens to that Body parameter in file:write_file and can I do  
that to the result of the http call before passing it erlsom:scan ?

Many thanks in advance if you can help

Cheers

Russell


More information about the erlang-questions mailing list