Validate S-expression against a DTD or equivalent?

Discussion in 'XML' started by Robert Dodier, Nov 4, 2003.

  1. 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
    Robert Dodier, Nov 4, 2003
    #1
    1. Advertising

  2. Robert Dodier

    Guest

    (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.
    , Nov 4, 2003
    #2
    1. Advertising

  3. Re: Validate [X-expression] against a DTD or equivalent?

    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
    james anderson, Nov 4, 2003
    #3
  4. Re: Validate [S-expression] against a DTD or equivalent?

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

    ....
    james anderson, Nov 4, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian J. Sayatovic
    Replies:
    0
    Views:
    383
    Brian J. Sayatovic
    Feb 10, 2004
  2. Stefan Ram

    Validating a DOM against a DTD?

    Stefan Ram, Jul 25, 2004, in forum: Java
    Replies:
    0
    Views:
    440
    Stefan Ram
    Jul 25, 2004
  3. Adib Taraben
    Replies:
    1
    Views:
    579
    Patrick TJ McPhee
    May 24, 2004
  4. Replies:
    0
    Views:
    1,228
  5. Andrew Thompson

    Validate XML against DTD? XSD OK. SSCCE.

    Andrew Thompson, Oct 3, 2007, in forum: Java
    Replies:
    5
    Views:
    2,805
    Roedy Green
    Oct 4, 2007
Loading...

Share This Page