The Mercury Project
Re: [mercury-users] XML / DOM

Home

News

Information
  Overview
  Features
  Documentation
  Papers
  Developers
  Events
  Reports

Mailing Lists
  Developers
  Users
  Search

Download
  Current Release
  Snapshot
  Old Releases

Related
  Applications
  MCORBA
  Contributing Code

Contact

Search

Subject: Re: [mercury-users] XML / DOM
From: Richard A. O'Keefe (ok@atlas.otago.ac.nz)
Date: Tue Dec 19 2000 - 10:21:38 EST


Michael Day <mikeday@corplink.com.au> asked:
        
        Has anyone tried a DOM implementation in Mercury?

Not me, but I *have* studied the level 1 and level 2 DOM specifications
in detail. It's hard to think of anything that would be less suitable
for Mercury. Come to think of it, it's hard to think of anything less
well designed for doing anything with XML in any language than the DOM.

When manipulating SGML or XML documents in languages like Erlang,
Prolog, Mercury, or Haskell it is normal to treat them as tree *values*.

For example, SWI Prolog basically uses
    element(ElementType, AttributeList, Children)
    entity(EntityName)
    pi(Text) -- split the PiName out yourself
    Atom -- character data

A little XML file like
    <example date="2000.12.19"><p><em>Hello</em>, world!</p></example>
would be returned as the value
    element(example, [date='2000.12.19'], [
      element(p, [], [
        element(em, [], ['Hello']),
        ', world!'])])
This is *far* easier to manipulate in a language like Mercury than
anything that treats a document as a collection of mutable objects
locked rigidly into place.

Take a look at HaXML. I mean, it is *so* much easier to use than DOM
that it really isn't funny.

My knowledge of interfacing Mercury to foreign code is not sufficiently
great to undertake a binding between Mercury and Jan Wielemaker's
sgml2pl library, but I think it would be rather useful.
        
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users@cs.mu.oz.au
administrative address: owner-mercury-users@cs.mu.oz.au
unsubscribe: Address: mercury-users-request@cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request@cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



This mail archive was generated by hypermail 2b25 on Sun Dec 31 2000 - 00:40:04 EST.