haxr - marshalling of Variants in Records

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

haxr - marshalling of Variants in Records

Johannes Waldmann
Any ideas for automatically marshalling
record types with variants for XML-RPC?
We need to put the "tag" information somewhere,
perhaps as a separate component of the TStruct
(but how should it be called).

Of course we can define what we want as long as client
and server use haxr, but in other cases?
Perhaps we should use some more general scheme (SOAP) then.

If the Haskell app is the defining side,
I'd love to just "derive Haskell2Xml" for my data,
and then I'd want a "haskell2scheme" (not: DTD)
so that the Java side can use a Schema->Java compiler (like xjc).

On the other hand if I have to use a given XML schema,
I want some "xhc" tool (Schema->Haskell).

Perhaps some of these projects are already out there?
--
-- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 --
---- http://www.imn.htwk-leipzig.de/~waldmann/ -------

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

Xml Schema and deriving Haskell2Xml, was Re: haxr - marshalling of Variants in Records

Shae Matijs Erisson
Johannes Waldmann <[hidden email]> writes:

> If the Haskell app is the defining side,
> I'd love to just "derive Haskell2Xml" for my data,
> and then I'd want a "haskell2scheme" (not: DTD)
> so that the Java side can use a Schema->Java compiler (like xjc).
>
> On the other hand if I have to use a given XML schema,
> I want some "xhc" tool (Schema->Haskell).
>
> Perhaps some of these projects are already out there?

See the new XmlContent type/module in HaXml 1.14:
http://nhc98.blogspot.com/2005/10/unifying-haskell2xml-and-xml2haskell.html

Relax NG was prototyped in Haskell, not sure if that helps any.

HAIFA does some sort of Xml Schema work.
There's an HAIFA article in the first issue of The Monad.Reader:
http://www.haskell.org/hawiki/TheMonadReader/IssueOne
--
Shae Matijs Erisson - http://www.ScannedInAvian.com/ - Sockmonster once said:
You could switch out the unicycles for badgers, and the game would be the same.

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

Re: Xml Schema and deriving Haskell2Xml, was Re: haxr - marshalling of Variants in Records

Simon Foster
Hi,

As Shae says, HAIFA can do XML Schema -> Haskell Mapping (if you can
call it Haskell); well at least it could, I've since done some
refactoring on the XML Serializer class so it won't work out of box, but
should work with some tweaking. I stopped working on it because in order
to map XML Schema properly I needed to break Haskell's type-system in
just about every way possible and the code was quite horrible. In order
to represent Sequences and Choices (the staple part of XML Schema
Complex-Types), you need HList and Union types, since structures within
a single complex-type can be quite ... err ... complex. As a result the
whole thing is undecidable and context stack overflows are not uncommon.
Nevertheless - it does work; it takes an XML Schema and produces a
Haskell module called things like Org.W3.N2001.XMLSchema with
serializers, but the data-types produced are pretty horrible and
undecidable - see the attachment generated from Google Search.
Fortunately as Google Search doesn't use either Sequences(/Interleaving)
or Union types in awkward places the types aren't too bad in this case.

The other problem you're likely to run up against is a lack of automatic
mutual module recursion support for Haskell, assuming you want to map
each schema namespace to a single module - there exists quite a lot of
examples of mutually recursive schemas. Certainly I haven't even
attempted to work round this problem yet.

If I get round to it, I'll try and get XML Schema serialization and
type-mapping work again; although it's pretty non-trivial to use. There
aren't any source distributions of HAIFA atm, though I can easily bring
the darcs repositories back online.

To be honest though, it may be better to do the type-mapping outside of
Haskell (anathema I know, but other languages do already have full
schema support) - this project seems to have made a reasonable start:
http://www.cin.ufpe.br/~haskell/hwsproxygen/, although the mapping they
do seems to be quite primitive at the moment, and even if the data-types
were created outside of Haskell, you'd still have to work out how to
represent Unions/embedded Sequences effectively.

Oh, and so far as XML Serializer derivation goes, HAIFA can do that
quite nicely with a number of xmlify* TH functions. Although I know
other libraries have this too and may do it better.

Thanks,

-Si.

On Mon, 2005-12-05 at 20:43 +0100, Shae Matijs Erisson wrote:

> Johannes Waldmann <[hidden email]> writes:
>
> > If the Haskell app is the defining side,
> > I'd love to just "derive Haskell2Xml" for my data,
> > and then I'd want a "haskell2scheme" (not: DTD)
> > so that the Java side can use a Schema->Java compiler (like xjc).
> >
> > On the other hand if I have to use a given XML schema,
> > I want some "xhc" tool (Schema->Haskell).
> >
> > Perhaps some of these projects are already out there?
>
> See the new XmlContent type/module in HaXml 1.14:
> http://nhc98.blogspot.com/2005/10/unifying-haskell2xml-and-xml2haskell.html
>
> Relax NG was prototyped in Haskell, not sure if that helps any.
>
> HAIFA does some sort of Xml Schema work.
> There's an HAIFA article in the first issue of The Monad.Reader:
> http://www.haskell.org/hawiki/TheMonadReader/IssueOne
> --
> Shae Matijs Erisson - http://www.ScannedInAvian.com/ - Sockmonster once said:
> You could switch out the unicycles for badgers, and the game would be the same.
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries

GoogleSearch1.hs (20K) Download Attachment