Haskell2Xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Haskell2Xml

Dmitry Olshansky
Hello all,

I need a convenient tool to generate Haskell types from XML W3C Schema Definition (xsd) and vice versa - generate instances for Haskell ADT's to make corresponding XML.
It is just the same that HaXml do with DTD. 

I need 
- using XSD
- support for unicode
- using xml-attributes as far as elements are very desirable
- by my opinion TemplateHaskell for generate instances is prefferable than using DrIFT (which used in HaXml) - both possibilities is great of course
- generation of xsd by Haskell type is a good feature also
and so on...

Does this tool exist? 

Do some articles / thoughts / standards / recomendations about correspondence between XML and Haskell ADT's exist? 

Best wishes,
Dmitry  

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

Keith Sheppard
Hello Dmitry,

I too was looking for something like this and came up empty. I
proposed something similar on the haskell_proposals reddit...

http://www.reddit.com/r/haskell_proposals/comments/8zhkx/haxb_and_haxws/

... but I was left with the impression that there isn't much interest.

-Keith

On Wed, Aug 5, 2009 at 3:49 PM, Dmitry Olshansky<[hidden email]> wrote:

> Hello all,
> I need a convenient tool to generate Haskell types from XML W3C Schema
> Definition (xsd) and vice versa - generate instances for Haskell ADT's to
> make corresponding XML.
> It is just the same that HaXml do with DTD.
> I need
> - using XSD
> - support for unicode
> - using xml-attributes as far as elements are very desirable
> - by my opinion TemplateHaskell for generate instances is prefferable than
> using DrIFT (which used in HaXml) - both possibilities is great of course
> - generation of xsd by Haskell type is a good feature also
> and so on...
> Does this tool exist?
> Do some articles / thoughts / standards / recomendations about
> correspondence between XML and Haskell ADT's exist?
> Best wishes,
> Dmitry
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>



--
keithsheppard.name
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

Jason Dagit-2


On Wed, Aug 5, 2009 at 5:10 PM, Keith Sheppard <[hidden email]> wrote:
Hello Dmitry,

I too was looking for something like this and came up empty. I
proposed something similar on the haskell_proposals reddit...

http://www.reddit.com/r/haskell_proposals/comments/8zhkx/haxb_and_haxws/

... but I was left with the impression that there isn't much interest.

Several years ago, (probably 2005) I wanted this as well.  I ended up hand crafting a DTD from the xsd and then using haxml.

Since xsd is xml maybe it's easiest to use xslt (or use haxml) and write it yourself?  I'm sure it would catch on once it exists.

Jason

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

Dmitry Olshansky
Like in Keith proposal I need it for working with web-services, maybe Xml transformations and so on. 
And I tried to make it by self with a partial success. To work with xml I only used "xml" package (Text.XML.Light). 

Now I am going to work a little (?) on this task to provide more standard and regular tool than I have now. So it is very interesting for me to learn any ideas (if exists) on this thing from community. 


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

John Lask
the paper:

Scripting XML with Generic Haskell

Frank Atanassow, Dave Clarke and Johan Jeuring

October 14, 2003



describes a translation from XML Schema to Haskell data types (like
dtd2haskell) in generic haskell, I believe that the code for the tool
described may also be available, how hard it would be to migrate over to
vanilla haskell+generics is another question....


----- Original Message -----
From: Dmitry Olshansky
To: Haskell cafe
Sent: Friday, August 07, 2009 7:31 PM
Subject: Re: [Haskell-cafe] Haskell2Xml


Like in Keith proposal I need it for working with web-services, maybe Xml
transformations and so on.
And I tried to make it by self with a partial success. To work with xml I
only used "xml" package (Text.XML.Light).


Now I am going to work a little (?) on this task to provide more standard
and regular tool than I have now. So it is very interesting for me to learn
any ideas (if exists) on this thing from community.






_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe 

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

John Lask
In reply to this post by Dmitry Olshansky
 
----- Original Message -----
Sent: Friday, August 07, 2009 7:31 PM
Subject: Re: [Haskell-cafe] Haskell2Xml

Like in Keith proposal I need it for working with web-services, maybe Xml transformations and so on. 
And I tried to make it by self with a partial success. To work with xml I only used "xml" package (Text.XML.Light). 

Now I am going to work a little (?) on this task to provide more standard and regular tool than I have now. So it is very interesting for me to learn any ideas (if exists) on this thing from community. 


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

Sean Leather
In reply to this post by John Lask

On Fri, Aug 7, 2009 at 12:05, John Lask <[hidden email]> wrote:
the paper:

Scripting XML with Generic Haskell
Frank Atanassow, Dave Clarke and Johan Jeuring
October 14, 2003

describes a translation from XML Schema to Haskell data types (like dtd2haskell) in generic haskell, I believe that the code for the tool described may also be available, how hard it would be to migrate over to vanilla haskell+generics is another question....

It looks like this almost might work in EMGM. They use a Label in addition to all the other representation structure elements. EMGM doesn't have a Label, but it might be useful to add it...

With any needed changes such as the Label done, migrating this Generic Haskell code to EMGM would not be difficult.

Sean

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

Dmitry Olshansky
Well, great thanks for interesting links. 

But definitely at first I need a time to try to understand what Generic Haskell and EMGM are.

Does it stronger than Template Haskell? Could it be explained briefly and simplistic for first impression? Could it be compared with SYB or TH?

Would it be applied to realisation of translation or to target Haskell code? 

Regards,
Dmitry


2009/8/7 Sean Leather <[hidden email]>

On Fri, Aug 7, 2009 at 12:05, John Lask <[hidden email]> wrote:
the paper:

Scripting XML with Generic Haskell
Frank Atanassow, Dave Clarke and Johan Jeuring
October 14, 2003

describes a translation from XML Schema to Haskell data types (like dtd2haskell) in generic haskell, I believe that the code for the tool described may also be available, how hard it would be to migrate over to vanilla haskell+generics is another question....

It looks like this almost might work in EMGM. They use a Label in addition to all the other representation structure elements. EMGM doesn't have a Label, but it might be useful to add it...

With any needed changes such as the Label done, migrating this Generic Haskell code to EMGM would not be difficult.

Sean


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re[2]: Haskell2Xml

Bulat Ziganshin-2
Hello Dmitry,

Friday, August 7, 2009, 3:04:37 PM, you wrote:

generic programming in haskell generally means SYB-like things and
Generic Haskell (at least i have read description of) was a extended
version of Haskell with built-in support for generic programming. i.e.
those type-specific operations that was implemented in SYB using type
hackery, were built-in in GH. you may also read

Comparing Libraries for Generic Programming in
Haskell [http://www.cs.uu.nl/research/techreps/repo/CS-2008/2008-010.pdf]

Comparing Approaches to Generic Programming in Haskell
[http://www.cs.uu.nl/~johanj/publications/ComparingGP.pdf]

> Well, great thanks for interesting links. 

> But definitely at first I need a time to try to understand what Generic Haskell and EMGM are.

> Does it stronger than Template Haskell? Could it be explained
> briefly and simplistic for first impression? Could it be compared with SYB or TH?
>  

> Would it be applied to realisation of translation or to target Haskell code? 

> Regards,
> Dmitry


> 2009/8/7 Sean Leather <[hidden email]>
>  

> On Fri, Aug 7, 2009 at 12:05, John Lask <[hidden email]> wrote:
>  
>  the paper:
>  
>  Scripting XML with Generic Haskell
>  Frank Atanassow, Dave Clarke and Johan Jeuring
>  October 14, 2003
>  
>  describes a translation from XML Schema to Haskell data types
> (like dtd2haskell) in generic haskell, I believe that the code for
> the tool described may also be available, how hard it would be to
> migrate over to vanilla haskell+generics is another question....
>  

> It looks like this almost might work in EMGM. They use a Label in
> addition to all the other representation structure elements. EMGM
> doesn't have a Label, but it might be useful to add it...
>  
>  With any needed changes such as the Label done, migrating this
> Generic Haskell code to EMGM would not be difficult.

> Sean
>  

>  


--
Best regards,
 Bulat                            mailto:[hidden email]

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml

Sean Leather
In reply to this post by Dmitry Olshansky
Hi Dmitry,

Well, great thanks for interesting links. 

But definitely at first I need a time to try to understand what Generic Haskell and EMGM are.

Generic Haskell (GH) is a language extension implementing datatype-generic programming features on top of Haskell. It is implemented using a preprocessor that compiles source to Haskell.

EMGM ("Extensible and Modular Generics for the Masses") is an example of a Haskell library that allows you to implement many of the GH functions directly in Haskell without a preprocessor.
 
Does it stronger than Template Haskell? Could it be explained briefly and simplistic for first impression? Could it be compared with SYB or TH?

Template Haskell is a syntax-based metaprogramming extension to Haskell. Many datatype-generic things can be done in TH, but it often takes a lot of work because you're generating syntax. EMGM actually uses TH to generate representation values of datatypes.

SYB is another example of a datatype-generic library. It uses a different representation of datatypes than EMGM and GH. As a result, the libraries support different kinds of functions (sometimes completely different, but sometimes the same and implemented differently).
 
Would it be applied to realisation of translation or to target Haskell code?

To use something like EMGM or SYB, one uses or develops functions for manipulating values of arbitrary datatypes. Think of what happens when you "derive (Eq, Read, Show)" for example. You are getting functions (==), read, and show that work for your datatype. You can do this same sort of thing with other functions in SYB and EMGM.

As for your use case, I don't know if one of the libraries can help you directly. You wanted to first get the datatypes from XML Schemas, and that's going to require something like HaXml. But once you do get those datatypes, you can use one of the many generic programming libraries to manipulate values without having to write your own functions.

For a tutorial on using EMGM and SYB, see our recently published tech. report:

Libraries for Generic Programming in Haskell
Johan Jeuring, Sean Leather, José Pedro Magalhães, and Alexey Rodriguez Yakushev
http://www.cs.uu.nl/research/techreps/UU-CS-2008-025.html

Sean

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml - Suggest looking at HXT

Max Cantor
In reply to this post by Dmitry Olshansky
Hi Dmitry,

I've been using HXT and its XmlPickler class for encoding and decoding  
between XML <-> Haskell types.  It takes a while to wrap your brain  
around the arrows based API for HXT (something I'm still working on)  
but it seems to be quite powerful and well maintained.

Also, I've written some Template Haskell code to derive instances for  
the XmlPickler class (so that types can automatically be encoded and  
decoded as XML.  Its not pretty, has bugs, and is far from perfect but  
I can send that to you if you'd like a way to get stared.

Max

On Aug 7, 2009, at 7:04 PM, Dmitry Olshansky wrote:

> Well, great thanks for interesting links.
>
> But definitely at first I need a time to try to understand what  
> Generic Haskell and EMGM are.
>
> Does it stronger than Template Haskell? Could it be explained  
> briefly and simplistic for first impression? Could it be compared  
> with SYB or TH?
>
> Would it be applied to realisation of translation or to target  
> Haskell code?
>
> Regards,
> Dmitry
>
>
> 2009/8/7 Sean Leather <[hidden email]>
>
> On Fri, Aug 7, 2009 at 12:05, John Lask <[hidden email]> wrote:
> the paper:
>
> Scripting XML with Generic Haskell
> Frank Atanassow, Dave Clarke and Johan Jeuring
> October 14, 2003
>
> describes a translation from XML Schema to Haskell data types (like  
> dtd2haskell) in generic haskell, I believe that the code for the  
> tool described may also be available, how hard it would be to  
> migrate over to vanilla haskell+generics is another question....
>
> It looks like this almost might work in EMGM. They use a Label in  
> addition to all the other representation structure elements. EMGM  
> doesn't have a Label, but it might be useful to add it...
>
> With any needed changes such as the Label done, migrating this  
> Generic Haskell code to EMGM would not be difficult.
>
> Sean
>
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell2Xml - Suggest looking at HXT

Dmitry Olshansky
Hi Max, thanks for your suggestion. 
I also have a "not pretty" code which used Text.XML.Light and TH. I am going to rewrite it. HXT by my opinion is too big.

The question is a "requirements". Which correlations exist between Haskell types and XML-Schema possibilities? How to prepare XML for different Haskell types? How to generate Haskell types from XML-Schema, which restrictions in schema could be authomatically modeled in Haskell? And so on...


2009/8/8 Max Cantor <[hidden email]>
Hi Dmitry,

I've been using HXT and its XmlPickler class for encoding and decoding between XML <-> Haskell types.  It takes a while to wrap your brain around the arrows based API for HXT (something I'm still working on) but it seems to be quite powerful and well maintained.

Also, I've written some Template Haskell code to derive instances for the XmlPickler class (so that types can automatically be encoded and decoded as XML.  Its not pretty, has bugs, and is far from perfect but I can send that to you if you'd like a way to get stared.

Max

On Aug 7, 2009, at 7:04 PM, Dmitry Olshansky wrote:

Well, great thanks for interesting links.

But definitely at first I need a time to try to understand what Generic Haskell and EMGM are.

Does it stronger than Template Haskell? Could it be explained briefly and simplistic for first impression? Could it be compared with SYB or TH?

Would it be applied to realisation of translation or to target Haskell code?

Regards,
Dmitry


2009/8/7 Sean Leather <[hidden email]>

On Fri, Aug 7, 2009 at 12:05, John Lask <[hidden email]> wrote:
the paper:

Scripting XML with Generic Haskell
Frank Atanassow, Dave Clarke and Johan Jeuring
October 14, 2003

describes a translation from XML Schema to Haskell data types (like dtd2haskell) in generic haskell, I believe that the code for the tool described may also be available, how hard it would be to migrate over to vanilla haskell+generics is another question....

It looks like this almost might work in EMGM. They use a Label in addition to all the other representation structure elements. EMGM doesn't have a Label, but it might be useful to add it...

With any needed changes such as the Label done, migrating this Generic Haskell code to EMGM would not be difficult.

Sean

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe