Hello,
Here's a thought that I'm sure has already occurred to
someone else, I just can't find any record of it yet.
An XML document is just a more verbose and clumsy representation
of an ordinary Lisp S-expression. So it's easy enough to translate
some XML into equivalent Lisp. Now I turn it over to the Lisp
parser, which creates the equivalent of the DOM for me.
However, having parsed an S-expression, the Lisp parser doesn't
go any farther; verifying that the expression contains some
particular set of nested tags is Somebody Else's Problem.
I'm not really interested in translating XML and XML DTD
notations into S-expressions. What really interests me is this:
is there some Lisp code out there to apply a DTD-like construct
(essentially a grammar) to validate an S-expression?
Thanks in advance for staying on topic. 8^)
Robert Dodier
·············@yahoo.com (Robert Dodier) writes:
> Hello,
>
> Here's a thought that I'm sure has already occurred to
> someone else, I just can't find any record of it yet.
>
> An XML document is just a more verbose and clumsy representation
> of an ordinary Lisp S-expression. So it's easy enough to translate
> some XML into equivalent Lisp. Now I turn it over to the Lisp
> parser, which creates the equivalent of the DOM for me.
>
> However, having parsed an S-expression, the Lisp parser doesn't
> go any farther; verifying that the expression contains some
> particular set of nested tags is Somebody Else's Problem.
>
> I'm not really interested in translating XML and XML DTD
> notations into S-expressions. What really interests me is this:
> is there some Lisp code out there to apply a DTD-like construct
> (essentially a grammar) to validate an S-expression?
Is an is... I once followed in the fad of "writing lisp generating
HTML" and built myself a couple of macros and support functions. The
gist was that I had a generator function taht actually morphed
argumnets to HTML and a macro named after the HTML tag I was
interested in, where the macro made sure that it only had "Correct
things" in it.
Of course, all that is boring, so I had a DEFTAG macro that took
"tag", "generator function" and "allowed tags".
//Ingvar
--
(defmacro fakelambda (args &body body) `(labels ((me ,args ,@body)) #'me))
(funcall (fakelambda (a b) (if (zerop (length a)) b (format nil "~a~a"
(aref a 0) (me b (subseq a 1))))) "Js nte iphce" "utaohrls akr")
From: ·············@comcast.net
Subject: Re: Validate S-expression against a DTD or equivalent?
Date:
Message-ID: <oevswk8c.fsf@comcast.net>
·············@yahoo.com (Robert Dodier) writes:
> Hello,
>
> Here's a thought that I'm sure has already occurred to
> someone else, I just can't find any record of it yet.
>
> An XML document is just a more verbose and clumsy representation
> of an ordinary Lisp S-expression. So it's easy enough to translate
> some XML into equivalent Lisp. Now I turn it over to the Lisp
> parser, which creates the equivalent of the DOM for me.
>
> However, having parsed an S-expression, the Lisp parser doesn't
> go any farther; verifying that the expression contains some
> particular set of nested tags is Somebody Else's Problem.
>
> I'm not really interested in translating XML and XML DTD
> notations into S-expressions. What really interests me is this:
> is there some Lisp code out there to apply a DTD-like construct
> (essentially a grammar) to validate an S-expression?
There are a lot of pattern matching programs that match on
s-expressions. Validating an S-expression with one of these would
simply be putting T as the consequence of matching the pattern.
Of course, when you use one of these pattern matching programs you
generally put something a bit more complicated than T or NIL as the
result clause. Thus you get validation and *computation*
simultaneously rather than needing an extra step.
From: james anderson
Subject: Re: Validate [X-expression] against a DTD or equivalent?
Date:
Message-ID: <3FA7762E.C5D6940D@setf.de>
Robert Dodier wrote:
>
> Hello,
>
> Here's a thought that I'm sure has already occurred to
> someone else, I just can't find any record of it yet.
>
> An XML document is just a more verbose and clumsy representation
> of an ordinary Lisp S-expression.
the abstract syntax of xml is, strictly speaking, not equivalent to an s-expression.
document models are annotated hypergraphs, which lack an "operator" in the
initial position in the expression. none of the various list-based models for
xml really have an s-expression form.
> So it's easy enough to translate
> some XML into equivalent Lisp.
it is easy to translates "some xml" into _lists_.
> Now I turn it over to the Lisp
> parser, which creates the equivalent of the DOM for me.
>
> However, having parsed an [X-expression], the Lisp parser doesn't
> go any farther; verifying that the expression contains some
> particular set of nested tags is Somebody Else's Problem.
>
> I'm not really interested in translating XML and XML DTD
> notations into S-expressions. What really interests me is this:
> is there some Lisp code out there to apply a DTD-like construct
> (essentially a grammar) to validate an [X-expression]?
>
the validation engine in cl-xml could be used to validate such data models.
on the other hand, where one has all sorts of lisp-based parsers and pattern
matchers at one's disposal, why would one want to bring dtd's into the picture?
> Thanks in advance for staying on topic. 8^)
>
> Robert Dodier
From: james anderson
Subject: Re: Validate [S-expression] against a DTD or equivalent?
Date:
Message-ID: <3FA779A7.52C566D0@setf.de>
james anderson wrote:
>
> Robert Dodier wrote:
> >
> > Hello,
> >
> > Here's a thought that I'm sure has already occurred to
> > someone else, I just can't find any record of it yet.
> >
> > An XML document is just a more verbose and clumsy representation
> > of an ordinary Lisp S-expression.
>
[ok, i went back and looked. the operator constraint was a figment of my imagination...]
...