willemdj / erlsom

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

Data binding: case insensitive parsing #66

Closed archseer closed 6 years ago

archseer commented 6 years ago

We're trying to parse a few wsdl files in which they didn't camel-case the attribute names. So something like

erlsom:scan(WsdlFile, WsdlModel)
<wsdl:definitions name="MyService" targetnamespace="http://example.com/"  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  ...
</wsdl:definitions>

will fail to parse with the xsd model we have 'Unexpected attribute: targetnamespace', because the correct definition is targetNamespace.

Would it be possible to parse these files case insensitive?

willemdj commented 6 years ago

Are you using erlsom_parseXsd:xsdModel() as the "model"? You could make a copy of the module erlsom_parseXsd that uses lower case strings for the tags. So line 75 would become:

atts = [#att{nm = targetnamespace, nr = 3, opt = true, tp = char},

for example. (I didn't try it...).

Or you could even create a function to modify the result of erlsom_parseXsd:xsdModel(), I guess.

Fixing the Wsdl files might be a better option...

God luck, Willem

archseer commented 6 years ago

Thanks, that worked! We also got the vendor to fix their implementation.

Unrelatedly, could I ask you to release a new package version on hex.pm? There's been quite a few changes since the last release, namely erlsom:write performance and write/3 now making it possible to output a binary instead.

I'm currently working on a elixir soap client that relies on write/3, so I'm unable to publish it on hex.pm (it doesn't allow git dependencies on published packages).

Lastly, thank you for erlsom!

archseer commented 6 years ago

Hi @willemdj, thanks for bumping the version to 1.4.2! Would it be possible to build and publish a hex.pm package for v1.4.2 as well? https://hex.pm/packages/erlsom

http://www.rebar3.org/v3.0/docs/publishing-packages

willemdj commented 6 years ago

Done. (Sorry that it took a while.)

archseer commented 6 years ago

Thank you!