[Haskell-cafe] configurable mapping between data declarations and given XML schema?

8 views
Skip to first unread message

Johannes Waldmann

unread,
May 30, 2016, 6:04:52 AM5/30/16
to haskel...@haskell.org
Dear Cafe,

I have a legacy XML schema, and some Haskell data declarations.
I want to map bidirectionally between XML documents and data.

I absolutely cannot change the schema. I could change the data
declarations, but it would not help much, since I don't think
there is any form of declaring data that would allow me
to derive the transformations generically.

So, I have a mess of ad-hoc transformations.
What could be done about this?
I think I need "generic with customization".

More detail: https://github.com/jwaldmann/haskell-tpdb/issues/16

Comments appreciated.

- J.W.
_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Erik Hesselink

unread,
May 30, 2016, 6:53:31 AM5/30/16
to Johannes Waldmann, haskell
Have you looked at the xml picklers from the hxt package [0]? They
allow you to define matching parsers and printers from XML, which
sounds exactly like your use case. You can define them manually, or
derive (parts of) them using the generic-xmlpickler package [1].

Regards,

Erik

[0] http://hackage.haskell.org/package/hxt-9.3.1.15/docs/Text-XML-HXT-Arrow-Pickle.html
[1] http://hackage.haskell.org/package/generic-xmlpickler

On 30 May 2016 at 12:04, Johannes Waldmann

Michael Burge

unread,
May 30, 2016, 6:54:54 AM5/30/16
to Johannes Waldmann, haskell-cafe
You can try the XsdToHaskell tool in HaXml. It might not work perfectly by itself, but with a little cleanup it'll probably save you some time.

I've also used TemplateHaskell to generate XML serializers for data declarations. If you write your own code generator, you can be as generic and customized as you need.
Reply all
Reply to author
Forward
0 new messages