Validate S-expression against a DTD or equivalent?

R

Robert Dodier

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
 
P

prunesquallor

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

james anderson

Robert said:
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?
 
J

james anderson

[ok, i went back and looked. the operator constraint was a figment of my imagination...]

....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top