Re: [Haskell] HaXml and XML Schema

2004-03-17 Thread Frank Atanassow
On Mar 10, 2004, at 8:56 AM, [EMAIL PROTECTED] wrote:
Example (readers familiar with the problem may
skip this):
salutationDear Mr.nameRobert Smith/name./salutation
This structure is represented by the XML Schema

xsd:element name=salutation
xsd:complexType mixed=true
xsd:sequence
xsd:element name=name type=xsd:string/
/xsd:sequence
/xsd:complexType
/xsd:element
How would you represent this in Haskell?
A first idea may be to store the enclosing strings:
data Salutation = Salutation String Name String

This approach is not scaling well. E.g., there may be multiple
names in the text...
No, according to the content model, there must be exactly one 
occurrence of name in the content of salutation: not zero, and not 
more than one. To allow zero or more you need to add minOccurs and/or 
maxOccurs attributes. This is one of the ways that mixed content in XML 
Schema differs from that in DTD's, and is treated in the references 
Johan posted.

So, on the contrary, your first declaration:

  data Salutation = Salutation String Name String

is a better translation of this schema (fragment), than your second 
attempt:

  data Salutation' = Salutation' [Either Char Name]

Regards,
Frank
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] HaXml and XML Schema

2004-03-11 Thread Steffen Mazanek
Hello,

thank you for the references. Looks promising. I will read
it carefully.

A nice solution I really like was found by Alastair Reid. He
proposed to me (hope it is ok to cite this) the declaration:

data Salutation = [Either Char Name]

We think it will not scale well, too, however, it is elegant due
to its simplicity.

Bye and thx,
Steffen
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] HaXml and XML Schema

2004-03-10 Thread Johan Jeuring
I have started thinking about an extension of
HaXml to better support XML Schema, i.e., to
generate appropriate types (like DtdToHaskell)
automatically (cf. Castor for Java).
However, it is not obvious to me how to model
mixed content (character data appears alongside
subelements, i.e., it is not confined to the
deepest subelement).
We have worked on a XML Schema Haskell data binding, see

Frank Atanassow, Dave Clarke, and Johan Jeuring. Scripting XML with 
Generic Haskell. In Proceedings of the 7th Brazilian Symposium on 
Programming Languages, SBLP 2003, 2003.

and for just the data binding

Frank Atanassow, Dave Clarke, and Johan Jeuring. UUXML: A 
Type-Preserving XML Schema Haskell Data Binding.

Both are available from my homepage:

http://www.cs.uu.nl/~johanj/publications/publications.html

The modelling of ,ixed content is rather intricate, I'm afraid.

-- Johan

___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell


[Haskell] HaXml and XML Schema

2004-03-09 Thread s_mazanek
Hello,

I have started thinking about an extension of
HaXml to better support XML Schema, i.e., to
generate appropriate types (like DtdToHaskell)
automatically (cf. Castor for Java).
However, it is not obvious to me how to model
mixed content (character data appears alongside
subelements, i.e., it is not confined to the
deepest subelement).

Example (readers familiar with the problem may
skip this):
salutationDear Mr.nameRobert Smith/name./salutation

This structure is represented by the XML Schema

xsd:element name=salutation
xsd:complexType mixed=true
xsd:sequence
xsd:element name=name type=xsd:string/
/xsd:sequence
/xsd:complexType
/xsd:element

How would you represent this in Haskell?
A first idea may be to store the enclosing strings:

data Salutation = Salutation String Name String

This approach is not scaling well. E.g., there may be multiple 
names in the text...

Do you have other ideas? 

Thank you and Happy Haskelling,
Steffen
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell