[mercury-users] XML / DOM
Richard A. O'Keefe
ok at atlas.otago.ac.nz
Tue Dec 19 10:21:38 AEDT 2000
Michael Day <mikeday at 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 at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list