[erlang-questions] \bclarify: Exception on erlsom:write_xsd_hrl_file for XMLSchema
Willem de Jong
w.a.de.jong@REDACTED
Sun Jun 7 16:05:00 CEST 2009
Hi Mike,
This is caused by the fact that the XSD contains a group and an element with
the same name. This causes a conflict. It can be solved by telling Erlsom to
put a prefix in front of one of them. If you try
erlsom:write_xsd_hrl_file("soap-1.1-encoding.xsd","hrl.hrl", [{group_prefix,
"G:"}]).
then it works. I tried to explain this in the documentation, but I have to
admit that it remains a bit of an obscure feature...
Regards,
Willem
On Sat, Jun 6, 2009 at 4:15 PM, Mike Ziebeck <mike@REDACTED> wrote:
> Willem de Jong schrieb:
>
>> Hello Mike,
>> If I understand correctly, most of your tests are using a WSDL file as
>> input for the erlsom:write_xsd_hrl_file() function. That doesn't work,
>> because this function expects an XSD as its input.
>>
> Hello Willem,
>
> indeed. My fault. Because of the in-document schema definition of those
> WSDL
> files I was a little too optimistic erlsom:write_xsd_hrl_file() could do
> the
> job. So for now I've got an other real world .xsd that erlsom cannot
> handle.
> It's the SOAP 1.1 .XSD found here:
> http://schemas.xmlsoap.org/soap/encoding/
> resulting in:
>
> erlsom_test: write_xsd_hrl_file_test_ (info: not working)...*failed*
> ::throw:{error,"Group or anonymous sequence nested too deep"}
> in function erlsom_writeHrl:writeXsdHrlFile/2
> in call from erlsom:write_xsd_hrl_file/3
>
> To reproduce that using eunit-2.1.1. see the attached unit testing
> modul.
>
> Regards,
> Mike
>
> -- Output as follows:
> =======================================================
> Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0]
>
> (node_a@REDACTED)1> erlsom_test:test().
> erlsom_test: write_xsd_hrl_file_test_ (info: not working)...*failed*
> ::throw:{error,
> [{exception,{error,{"2 - Unexpected event, expected end-tag"}}},
> {stack,[schemaType]},
> {received,
> {startElement,"http://www.w3.org/2001/XMLSchema","notation",
> "xs",
> [{attribute,"system",[],[],
> "http://www.w3.org/2000/08/XMLSchema.xsd"},
> {attribute,"public",[],[],[...]},
> {attribute,"name",[],[],...}]}}]}
> in function erlsom_writeHrl:writeXsdHrlFile/2
> in call from erlsom:write_xsd_hrl_file/3
>
>
> erlsom_test: write_xsd_hrl_file_test_ (info: not working)...*failed*
> ::throw:{error,"Group or anonymous sequence nested too deep"}
> in function erlsom_writeHrl:writeXsdHrlFile/2
> in call from erlsom:write_xsd_hrl_file/3
>
>
> =======================================================
> Failed: 2. Skipped: 0. Passed: 7.
> error
>
>
> %%%
> ===========================================================================
> %%% Author © 2009: Mike Ziebeck
> %%% Description: unit tests for erlsom
> %%% Created: 06.06.2009
> %%%
> ===========================================================================
> -module(erlsom_test).
>
> %%
> %% Include files
> %%
> -include_lib("eunit/include/eunit.hrl").
>
> %%
> %% Exported Functions
> %%
>
> %%
> %% API Functions
> %%
>
> %%
> %% Description: try to write_xsd_hrl_file using some real world .XSD's
> %%
> write_xsd_hrl_file_test_() ->
> [{timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"xml","http://www.w3.org/2009/01/xml.xsd",[]}) end}},
> {timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"soap_envelope12","http://www.w3.org/2003/05/soap-envelope",
> [{include_files, [{"http://www.w3.org/XML/1998/namespace","xs","xml.xsd"}]}]})
> end}},
> {timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"soap_envelope11","http://schemas.xmlsoap.org/soap/envelope/",[]})
> end}},
> {timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"soap_encoding12","http://www.w3.org/2003/05/soap-encoding",[]})
> end}},
> {timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"xml_schema_hfp","
> http://www.w3.org/2001/XMLSchema-hasFacetAndProperty",[]}) end}},
> {timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"xhtml","http://www.w3.org/1999/xhtml.xsd",[]}) end}},
> {timeout, 5000, {"info: working", fun() -> write_xsd_hrl_file_test(
> {"xml_schema_instance","http://www.w3.org/2001/XMLSchema-instance",[]})
> end}},
> {timeout, 5000, {"info: not working", fun() ->
> write_xsd_hrl_file_test(
> {"xml_schema","http://www.w3.org/2001/XMLSchema.xsd",
> [{include_files, [{"http://www.w3.org/XML/1998/namespace","xs","xml.xsd"}]}]})
> end}},
> {timeout, 5000, {"info: not working", fun() -> write_xsd_hrl_file_test(
> {"soap_encoding11","http://schemas.xmlsoap.org/soap/encoding/",[]})
> end}}
> ].
>
> %%
> %% Local Functions
> %%
>
> %%
> %% Description: .XSD download & compile into .hrd via write_xsd_hrl_file
> %%
> write_xsd_hrl_file_test({Prefix, Url, Options}) ->
> inets:start(),
> FileName = filename:join([filename:dirname(code:which(?MODULE)),
> Prefix]),
> {ok, {{"HTTP/1.1", 200, "OK"}, _HeadRcv, Body}} = http:request(Url),
> file:write_file(FileName++".xsd", list_to_binary(Body)),
> erlsom:write_xsd_hrl_file(FileName++".xsd", FileName++".hrl",
> Options).
>
More information about the erlang-questions
mailing list