[mercury-users] XML / DOM

Thomas Conway conway at cs.mu.OZ.AU
Tue Dec 19 11:04:54 AEDT 2000


On Tue, Dec 19, 2000 at 10:21:38AM EST, Richard A. O'Keefe wrote:
> 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*.

I agree with you that a *real* tree is much nicer to deal with than
an indirect representation, however I would note that if you're dealing
with beasts such as XPath, then it is rather inconvenient that the
nodes in the document tree don't have identity. Being able to deal
nicely with IDREF[S] and so forth using `pointers' is rather useful.

What would be nice is to have your cake and eat it. ML lets you (at
some cost, which you might very well argue is not worth paying) by
letting you have references to values. Like it or not, pointers/identity
lets you perform some operations MUCH more efficiently. For example
consider the case where I want the parent of a node. If I have only
values, first I have to unify subtrees to search for matches (which
may be arbitarily expensive), and even then I have no way of knowing
if this is the *real* parent, or if there is more than one possible
parent (unless I return all possible parents, but then we have the
same problem all over again).

Without node identity, it would be almost impossible to implement
XPath and XSLT efficiently.

-- 
 Thomas Conway              Mercurian )O+  
 <conway at cs.mu.oz.au>       Every sword has two edges.
--------------------------------------------------------------------------
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