erlsom data binder mode - question

  • Anonymous - 2008-07-04

    Hello.  I have a question about erlsom data binder mode (and probably indirectly about xml schema).

    I'm trying out erlsom in the following way:

             %% scan data
             io:format("~p: scan~n", [Name]),
             {ok, Input2, _} = erlsom:scan(Xml, SyncMLModel),
             io:format("scan in: ~p~n", [Input2]),
             {ok, Output2} = erlsom:write(Input2, SyncMLModel),
             io:format("scan out: ~p~n", [Output2]),
             %% check equality
             {ok, Input2, _} = erlsom:scan(Output2, SyncMLModel),

    I'm interested a feature such that if conversion of an xml complex type (see below) fails that the corresponding value of the erlang record field can contain the raw xml in binary format rather than being left as undefined.

      <xs:complexType mixed="true" name="Data">
          <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>

    Is this type of behavior possible?


    • Willem de Jong

      Willem de Jong - 2008-07-06

      Hello Joseph,

      I am not quite sure I understand what you mean, but I can say the following about 'any' types:

      With the current version you will only get output for 'any-types' if erlsom 'knows' the schema of the types are used in the XML instance. This can be types from another schema/namespace; you should use the 'add_xsd_file' function to make this work.

      If you do not specify a schema for these types, you currently will not get any output. Often it may be worthwhile to define a schema - after all, if you want to process the data, you should know what to expect, and you should be able to describe this in a schema.

      However, I understand that there may be cases where this is not possible. For example if you just need to pass the data to another application, without the need to actually understand it. Therefore I agree that it would be a useful feature if you could get access to this kind of data.

      I had a go at this today, and it turned out to be fairly straight forward. I will include this functionality in the next release. If you require it now, I could send you the code, or I could post it here. It could use some additional work, but I believe it should give you the functionality you need.

      My modification doesn't do exactly what you proposed: in stead of unparsed, binary data, it gives you the parsed xml in the generic 'simple form'. It is easy to transform this back into xml, if that is what you want.

      Let me know if you would like to get this fix, or if the answer is not clear,

      • Anonymous - 2008-07-06

        Willem - Thanks, your answer is clear and matches the desired feature.  I'd like to try out this patch before the next release.  Please post here when you have the chance.  thanks.

    • Willem de Jong

      Willem de Jong - 2008-07-07

      Hello Joseph,

      I just discovered that I can't add attachments here. I'll send the files to your sourceforge mail address, I hope that works.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks