[mercury-users] XML / DOM

Thomas Conway conway at cs.mu.OZ.AU
Tue Dec 19 12:52:00 AEDT 2000


On Tue, Dec 19, 2000 at 12:26:54PM EST, Richard A. O'Keefe wrote:
> 	If I have only
> 	values, first I have to unify subtrees to search for matches (which
> 	may be arbitarily expensive),
> 
> Wrong.
> 
> 	and even then I have no way of knowing
> 	if this is the *real* parent,
> 
> Wrong.
> 
> 	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).
> 	
> and Wrong again.
> 

Well, at least I got an unequivocal response! ;-)

So are you suggesting that nodes be identified by contatining a `thingy'
that uniquely identifies them? eg

:- type element
	--->	element(
		    id		:: thingy,
		    name	:: qName,
		    attrs	:: [(qName - string)],
		    kids	:: [content]
		).

:- type content
	--->	element(element)
	;	data(string)
	;	comment(string)
	;	pi(string, string)
			% should probably be:
			%	pi(qName, string)
			% but the XML Names rec is broken
	.

Without having thought long and hard about it, although this gives an
O(N) way of locating the parent, an ancestor, or sibling, I don't see
how to get any of these (in particular the first or last) in O(1) which
you can using pointers in C/C++.

If you could either provide a sketch of how this is done, or a link
to your paper, then that would be very useful.

> 	Without node identity, it would be almost impossible to implement
> 	XPath and XSLT efficiently.
> 	
> I have no idea about implementing XSLT; I've tried to read the spec and
> was so disgusted that I have trouble thinking about it.  Yet another typical
> W3C spec with oodles of syntax, but only warm fuzzies where the hard parts
> of semantics are concerned.

Indeed, the spec is light on semantics, however XSLT is nonetheless
quite a nice *declarative* way of transforming documents.

-- 
 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