<div>Hello Mike,</div>
<div> </div>
<div>You are right, erlsom fails on the xml schema for xml schema. I have to admit that I wasn't aware of this. </div>
<div> </div>
<div>I had a first look:</div>
<div>- the schema for schema uses the "notation" element. Erlsom doesn't support that - I don't really know what it is supposed to mean or what to do with it. I also haven't seen any other XSD that uses it, so far.</div>
<div> </div>
<div>- removing the "notation" elements doesn't solve the problem, so there is another problem somewhere - I'll try to find out whether or not this is related to the fact that the schema is sort of defining itself - this is a rather unique case.<br>
</div>
<div>If you just wanted to test the capabilities of Erlsom, then I suggest you do a couple more tests with more "normal" schema's (let me know if you encounter more problems..). While developing the tool I used the schema for voiceXML as a kind of benchmark, maybe it is an idea to look at that. It is quite big and complex - it is amazing how over-engineered some of these schemas are.</div>
<div> </div>
<div>If you really want to use the schema-schema, for example to parse XSDs and somehow transform them, or to extract information from them or something like that, then you can try using the "model" for XML schema that Erlsom itself uses. The function erlsom_parseXsd:xsdModel() returns this model. </div>
<div> </div>
<div>For example, you could do:</div>
<div><font face="courier new,monospace">15> erlsom:scan_file("BookStore.xsd", erlsom_parseXsd:xsdModel()).</font></div>
<div><font face="Courier New"></font> </div>
<div>the result will look something like this:</div>
<div> </div>
<div><font face="courier new,monospace">{ok,{schemaType,[],"</font><a href="http://www.books.org%22,%22qualified/" target="_blank"><font face="courier new,monospace">http://www.books.org","qualified</font></a><font face="courier new,monospace">",<br>
undefined,undefined,undefined,undefined,undefined,<br> [{globalElementType,[],"BookStore",undefined,undefined,<br> undefined,undefined,undefined,undefined,undefined,undefined,<br> undefined,<br>
{localComplexTypeType,[],undefined,...},<br> undefined},<br> {globalElementType,[],"Book",undefined,undefined,undefined,<br> undefined,undefined,undefined,undefined,undefined,undefined,<br>
{localComplexTypeType,[],...},<br> undefined},<br> {globalElementType,[],"Title",<br> {qname,"</font><a href="http://www.w3.org/2001/XMLSchema%22,%22string%22,%5B%5D,%22xsd" target="_blank"><font face="courier new,monospace">http://www.w3.org/2001/XMLSchema","string",[],"xsd</font></a><font face="courier new,monospace">"},<br>
undefined,undefined,undefined,...</font></div>
<div><font face="Courier New"></font> </div>
<div>The definitions of the records (schemaType, globalElementType etc.) are in erlsom_compile.hrl, so if you do <font face="courier new,monospace">rr("erlsom_compile.hrl")</font> first, the results will look like this:<br>
</div>
<div><font face="courier new,monospace">{ok,#schemaType{<br> elInfo = [],targetNamespace = "</font><a href="http://www.books.org/"><font face="courier new,monospace">http://www.books.org</font></a><font face="courier new,monospace">",<br>
elementFormDefault = "qualified",<br> attributeFormDefault = undefined,blockDefault = undefined,<br> finalDefault = undefined,version = undefined,<br> imports = undefined,<br> elements = <br>
[#globalElementType{<br> elInfo = [],name = "BookStore",type = undefined,<br> default = undefined,fixed = undefined,id = undefined,<br> abstract = undefined,substitutionGroup = undefined,<br>
final = undefined,nillable = undefined,<br> annotation = undefined,<br> simpl...</font></div>
<div> </div>
<div>Regards,</div>
<div>Willem<br></div>
<div> </div>
<div class="gmail_quote">On Wed, May 20, 2009 at 1:51 PM, Mike Ziebeck <span dir="ltr"><<a href="mailto:mike@ziebeck.net" target="_blank">mike@ziebeck.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I thought the schema <a href="http://w3.org/2001/XMLSchema.xsd" target="_blank">w3.org/2001/XMLSchema.xsd</a><br>
is rather significant regarding XML. So I was<br>a bit surprised seeing erlsom:write_xsd_hrl_file<br>throwing an Exception. See the attached file for<br>reproduction code.<br><br>Is there any work in progress fixing this issue?<br>
<br>Error Message:<br>** exception throw: {error,<br> [{exception,<br> {error,<br> {"2 - Unexpected event, expected end-tag"}}},<br> {stack,[schemaType]},<br>
{received,<br> {startElement,<br> "<a href="http://www.w3.org/2001/XMLSchema" target="_blank">http://www.w3.org/2001/XMLSchema</a>",<br>
"notation","xs",<br> [{attribute,"system",[],[],<br> "<a href="http://www.w3.org/2000/08/XMLSchema.xsd" target="_blank">http://www.w3.org/2000/08/XMLSchema.xsd</a>"},<br>
{attribute,"public",[],[],"structures"},<br> {attribute,"name",[],[],<br> "XMLSchemaStructures"}]}}]}<br>
in function erlsom_writeHrl:writeXsdHrlFile/2<br> in call from erlsom:write_xsd_hrl_file/3<br><font color="#888888"><br>--<br>System: Erlang R13B (erts-5.7.1) [smp:2:2] [rq:2] [async-threads:0] [WinXP64]<br> <br>
<br><br><br><br><br></font><br>%% Author: Mike Ziebeck<br>%% Created: 20.05.2009<br>%% Description: Test case modul for erlsom<br>-module(erlsomtest).<br><br>%%<br>%% Include files<br>%%<br><br>%%<br>%% Exported Functions<br>
%%<br>-export([test/0]).<br><br>%%<br>%% API Functions<br>%%<br><br>%%<br>%% function: test/0<br>%% description: download + write *.hdr file for <a href="http://www.w3.org/2001/XMLSchema" target="_blank">www.w3.org/2001/XMLSchema</a><br>
%%<br>test() -><br> %% not working<br> {Prefix,Url}={"xml_schema","<a href="http://www.w3.org/2001/XMLSchema.xsd" target="_blank">http://www.w3.org/2001/XMLSchema.xsd</a>"},<br> %% working<br>
%% {Prefix,Url}={"soap_envelope","<a href="http://schemas.xmlsoap.org/soap/envelope/" target="_blank">http://schemas.xmlsoap.org/soap/envelope/</a>"},<br> inets:start(),<br> FileName = filename:join([filename:dirname(code:which(?MODULE)), Prefix]),<br>
{ok, {{"HTTP/1.1", 200, "OK"}, _HeadRcv, Body}} = http:request(Url),<br> file:write_file(FileName++".xsd", list_to_binary(Body)),<br> erlsom:write_xsd_hrl_file(FileName++".xsd", FileName++".hrl").<br>
<br>%%<br>%% Local Functions<br>%%<br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br>