axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] RE: XML


From: Page, Bill
Subject: [Axiom-developer] RE: XML
Date: Wed, 15 Jun 2005 02:06:47 -0400

On Wednesday, June 15, 2005 12:01 AM Tim Daly wrote:

> 
> <spadcommand bound="x">{x:=2}</spadcommand>
> <spadcommand bound="y">{y:=3}</spadcommand>
> <spadcommand free="x,y">{x*y}</spadcommand>
> 
> requires a huge program to parse (DOM or SAX, callbacks) vs

No. This syntax can be easily described as a regular expression
that in principle requires nothing more complex than a simple
finite state machine to recognize. The equivalent of this has
been done in every web browser since the beginning of time. DOM,
SAX and the mechanism of callbacks refers to some specific (large
and complex) API library which may or may not be suitable to the
a depending on what one wants to do. I think this says it quite
well:

http://www.megginson.com/blogs/quoderat/archives/2005/02/08/the-complexity-o
f-xml-parsing-apis/

> (spadcommand "x:=2" (bound 'x))
> (spadcommand "y:=3" (bound 'y))
> (spadcommand "x*y" (free '(x y)))
>
> requires (read) to parse and (eval (read)) to execute.
> 
> (defun spadcommand (expr bindings)
>  (when (eq (car bindings) 'bound) (hashput (cdr bindings) expr))
>  (when (eq (car bindings) 'free)  (axiomeval (hashget (cdr bindings))))
>  (axiomeval expr))

This comparison is not reasonable since the parser you are using
is just built-in to lisp. How large is the resulting lisp code (on
typical hardware) compared to the size of the DOM and SAX libaries?
More or less the same, I expect.

There are better ways to do this. My choice for a simple "one-off"
programming problem would be a hand written recursive decent parser
consisting of a few simple routines. In C this probably wouldn't be
much larger than your lisp code.

Maybe someday I might try it this way:

http://www.codeproject.com/cpp/yard-xml-parser.asp

But these days, if a more general and complex task demands it and
it isn't a transformation that I could easily do with an XSLT
template, then I would probably choose StAX or some derivative.
For example:

http://www.oracle.com/technology/oramag/oracle/03-sep/o53devxml.html

http://www.xmlpull.org/history/index.html

http://www.extreme.indiana.edu/xgws/xsoap/xpp/mxp1/

Anyway, all this is irrelevant if one starts with the assumption that
a web browser already exists that understands the syntax. No new
programming is necessary.

Regards,
Bill Page.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]