willemdj / erlsom

XML parser for Erlang
GNU Lesser General Public License v3.0
264 stars 103 forks source link

XML signature #65

Closed gabbian1 closed 6 years ago

gabbian1 commented 6 years ago

Hello,

I have a question about create an signature in xml using this tool, how can I to do it?

Thanks,

Pacheco.

willemdj commented 6 years ago

Do you have a schema (xsd) for the xml document that you need to create? If so you can use erlsom:write/2 (or erlsom:write/3).

erlsom:write(Data, Model).

Data is the Erlang representation of your signature (in the form of a record). Model is the internal representation of the XSD.

To get the Model you need to compile your schema: erlsom:compile_xsd(Xsd).

You can get the definitions of the record format (a .hrl file) that you must use to specify the Data by using erlsom:write_xsd_hrl_file/3.

If you do not have an xsd, then you can probably not really use erlsom to create an XML file.

Good luck, Willem

gabbian1 commented 6 years ago

Hi @willemdj,

Thanks for explain :)

Data is the Erlang representation of your signature (in the form of a record). Model is the internal representation of the XSD.

It can be a data signed by a certificate ? My requeriment is prepare a xml file (also by XSD schema) and sign it by a especific certificate.

Br,

willemdj commented 6 years ago

If you simply need to sign the XML document, you can do that after encoding it with erlsom. If there are other requirements (like the XML needing to be in canonical form, ...) then I don't know, you'll have to figure it out yourself...

Good luck, Willem

gabbian1 commented 6 years ago

Okay, I'll try it (And close this issue) ;)

All best to you too!