From: vttoonses
Subject: Help with metaclass definitions
Date: 
Message-ID: <30968e93-865c-45ec-bad6-bb997a78634a@79g2000hsk.googlegroups.com>
I know I am probably messing in areas I shouldn't be (based on my
limited knowledge of Common Lisp), but I have a desire to create an
object to xml marshaller. Basically, I am building a webapp that has a
RESTful interface that a javascript and flex based UI is communicating
with.

Originally, I thought to create my response objects and have generic
functions that generated xml for each one. Then I thought, "Why do
that if I can write code to examine each object's structure and data?
Then I could write generalized code to convert any object to xml." A
little research into MOP and I was soon able to extract almost all the
information I needed. The only aspect that I need is to know whether a
data item is a child node, text, or attribute.

I've initially solved this by using the :documentation key for each
slot. I just put an indicator in there and when the marshaller is
examining the object, it pulls this data. This is ok and works, but
I'm hijacking a key for my own purposes. I'd rather be able to define
my own slot key(s) for the meta information the marshaller needs (node
type, namespace, etc).

Now we (finally) get to my issue - I've determined that I need to
define a meta class so that I may define my own slot keys.
Unfortunately, I'm receiving an error when attempting this.

(defclass my-meta-class (standard-class) ())

gives the following - (DEFCLASS MY-META-CLASS): superclass #<STRUCTURE-
CLASS STANDARD-CLASS> should be of class STANDARD-CLASS

I am using clisp 2.33 on windows (Lisp in a box) and Clozure CL on OSX
(leopard) and get the same in each case. Either they both have the
same issue or (much more likely) I'm doing something wrong. Any help
would be greatly appreciated. Additionally, if there is already a
mapping tool available that I should be using that someone knows
about, please let me know.

Thanks,
Gene

From: Rainer Joswig
Subject: Re: Help with metaclass definitions
Date: 
Message-ID: <joswig-AD87FE.17275816092008@news-europe.giganews.com>
In article 
<····································@79g2000hsk.googlegroups.com>,
 vttoonses <·········@gmail.com> wrote:

> I know I am probably messing in areas I shouldn't be (based on my
> limited knowledge of Common Lisp), but I have a desire to create an
> object to xml marshaller. Basically, I am building a webapp that has a
> RESTful interface that a javascript and flex based UI is communicating
> with.
> 
> Originally, I thought to create my response objects and have generic
> functions that generated xml for each one. Then I thought, "Why do
> that if I can write code to examine each object's structure and data?
> Then I could write generalized code to convert any object to xml." A
> little research into MOP and I was soon able to extract almost all the
> information I needed. The only aspect that I need is to know whether a
> data item is a child node, text, or attribute.
> 
> I've initially solved this by using the :documentation key for each
> slot. I just put an indicator in there and when the marshaller is
> examining the object, it pulls this data. This is ok and works, but
> I'm hijacking a key for my own purposes. I'd rather be able to define
> my own slot key(s) for the meta information the marshaller needs (node
> type, namespace, etc).
> 
> Now we (finally) get to my issue - I've determined that I need to
> define a meta class so that I may define my own slot keys.
> Unfortunately, I'm receiving an error when attempting this.
> 
> (defclass my-meta-class (standard-class) ())
> 
> gives the following - (DEFCLASS MY-META-CLASS): superclass #<STRUCTURE-
> CLASS STANDARD-CLASS> should be of class STANDARD-CLASS
> 
> I am using clisp 2.33 on windows (Lisp in a box) and Clozure CL on OSX
> (leopard) and get the same in each case. Either they both have the
> same issue or (much more likely) I'm doing something wrong. Any help
> would be greatly appreciated. Additionally, if there is already a
> mapping tool available that I should be using that someone knows
> about, please let me know.
> 
> Thanks,
> Gene

Maybe you need to update your Lisp implementations?
I don't get an error in CLISP 2.45 and CCL 1.2.

-- 
http://lispm.dyndns.org/
From: John Thingstad
Subject: Re: Help with metaclass definitions
Date: 
Message-ID: <op.uhky79ntut4oq5@pandora.alfanett.no>
P� Tue, 16 Sep 2008 15:51:52 +0200, skrev vttoonses <·········@gmail.com>:

> I know I am probably messing in areas I shouldn't be (based on my
> limited knowledge of Common Lisp), but I have a desire to create an
> object to xml marshaller. Basically, I am building a webapp that has a
> RESTful interface that a javascript and flex based UI is communicating
> with.
>
> Originally, I thought to create my response objects and have generic
> functions that generated xml for each one. Then I thought, "Why do
> that if I can write code to examine each object's structure and data?
> Then I could write generalized code to convert any object to xml." A
> little research into MOP and I was soon able to extract almost all the
> information I needed. The only aspect that I need is to know whether a
> data item is a child node, text, or attribute.
>
> I've initially solved this by using the :documentation key for each
> slot. I just put an indicator in there and when the marshaller is
> examining the object, it pulls this data. This is ok and works, but
> I'm hijacking a key for my own purposes. I'd rather be able to define
> my own slot key(s) for the meta information the marshaller needs (node
> type, namespace, etc).
>
> Now we (finally) get to my issue - I've determined that I need to
> define a meta class so that I may define my own slot keys.
> Unfortunately, I'm receiving an error when attempting this.
>
> (defclass my-meta-class (standard-class) ())
>
> gives the following - (DEFCLASS MY-META-CLASS): superclass #<STRUCTURE-
> CLASS STANDARD-CLASS> should be of class STANDARD-CLASS
>
> I am using clisp 2.33 on windows (Lisp in a box) and Clozure CL on OSX
> (leopard) and get the same in each case. Either they both have the
> same issue or (much more likely) I'm doing something wrong. Any help
> would be greatly appreciated. Additionally, if there is already a
> mapping tool available that I should be using that someone knows
> about, please let me know.
>
> Thanks,
> Gene

For the record have you looked at the code for cl-store? It has a  
deprecated module that translates Lisp objects to XML. Another module  
cl-prevalence does a ACID in memory database an mirrors data onto a disc  
using XML. Perhaps this could be used or save you some time? (Getting MOP  
to work portably is pain in the A**...)

--------------
John Thingstad
From: ······@corporate-world.lisp.de
Subject: Re: Help with metaclass definitions
Date: 
Message-ID: <aeabbbb2-d161-4404-adda-b9681ffbd9f4@j22g2000hsf.googlegroups.com>
On Sep 16, 5:41 pm, "John Thingstad" <·······@online.no> wrote:
> På Tue, 16 Sep 2008 15:51:52 +0200, skrev vttoonses <·········@gmail.com>:
>
>
>
> > I know I am probably messing in areas I shouldn't be (based on my
> > limited knowledge of Common Lisp), but I have a desire to create an
> > object to xml marshaller. Basically, I am building a webapp that has a
> > RESTful interface that a javascript and flex based UI is communicating
> > with.
>
> > Originally, I thought to create my response objects and have generic
> > functions that generated xml for each one. Then I thought, "Why do
> > that if I can write code to examine each object's structure and data?
> > Then I could write generalized code to convert any object to xml." A
> > little research into MOP and I was soon able to extract almost all the
> > information I needed. The only aspect that I need is to know whether a
> > data item is a child node, text, or attribute.
>
> > I've initially solved this by using the :documentation key for each
> > slot. I just put an indicator in there and when the marshaller is
> > examining the object, it pulls this data. This is ok and works, but
> > I'm hijacking a key for my own purposes. I'd rather be able to define
> > my own slot key(s) for the meta information the marshaller needs (node
> > type, namespace, etc).
>
> > Now we (finally) get to my issue - I've determined that I need to
> > define a meta class so that I may define my own slot keys.
> > Unfortunately, I'm receiving an error when attempting this.
>
> > (defclass my-meta-class (standard-class) ())
>
> > gives the following - (DEFCLASS MY-META-CLASS): superclass #<STRUCTURE-
> > CLASS STANDARD-CLASS> should be of class STANDARD-CLASS
>
> > I am using clisp 2.33 on windows (Lisp in a box) and Clozure CL on OSX
> > (leopard) and get the same in each case. Either they both have the
> > same issue or (much more likely) I'm doing something wrong. Any help
> > would be greatly appreciated. Additionally, if there is already a
> > mapping tool available that I should be using that someone knows
> > about, please let me know.
>
> > Thanks,
> > Gene
>
> For the record have you looked at the code for cl-store? It has a
> deprecated module that translates Lisp objects to XML. Another module
> cl-prevalence does a ACID in memory database an mirrors data onto a disc
> using XML. Perhaps this could be used or save you some time? (Getting MOP
> to work portably is pain in the A**...)
>
> --------------
> John Thingstad

Also http://www.agentsheets.com/lisp/XMLisp/
From: John Thingstad
Subject: Re: Help with metaclass definitions
Date: 
Message-ID: <op.uhk6myyvut4oq5@pandora.alfanett.no>
P� Tue, 16 Sep 2008 17:49:04 +0200, skrev ······@corporate-world.lisp.de  
<······@corporate-world.lisp.de>:

>
> Also http://www.agentsheets.com/lisp/XMLisp/
>

Cool. Missed that one. Seems perfect for implementing AIML. Been working  
through PAIP lately and ALICE, the modern evolvement of ELIZA would be a  
interesting study.

--------------
John Thingstad
From: John Thingstad
Subject: Re: Help with metaclass definitions
Date: 
Message-ID: <op.uhlp3x2iut4oq5@pandora.alfanett.no>
P� Tue, 16 Sep 2008 17:49:04 +0200, skrev ······@corporate-world.lisp.de  
<······@corporate-world.lisp.de>:

>
> Also http://www.agentsheets.com/lisp/XMLisp/
>

To make it a bit more user friendly I changed to load as a ASDF library  
and added a defpackage.
Here is how:

1. Make a directory XMLisp
2. Copy XMLisp.lisp there (The 3.03 version)
3. Change (in-package :XML) to (in-package :XMLisp)
4. Remove (the deprecated) import and export statements
5. add the following files:

XMLisp.asd

(in-package :cl-user)

(defpackage :XMLisp-asd
   (:use :cl :asdf))

(in-package :XMLisp-asd)

(defsystem :XMLisp-sys
   :serial t
   :components ((:file "packages")
                (:file "XMLisp")))

packages.lisp:

(defpackage :XMLisp
   ;; each MOP implementation appears to keep its symbols in a different,
   ;; application specific package: how clever!!
   ;; probably not a good idea to just USE that entire package
   #+:mcl
   (:import-from "CCL"
    "SLOT-DEFINITION-NAME"
    "SLOT-DEFINITION-TYPE"
    "SLOT-DEFINITION-INITFORM")
   #+(or :ccl-5.1 :openmcl)
   (:import-from "CCL"
    "CLASS-SLOTS")
   #+:clisp
   (:import-from "CLOS"
    "CLASS-SLOTS"
    "SLOT-DEFINITION-NAME"
    "SLOT-DEFINITION-TYPE"
    "SLOT-DEFINITION-INITFORM")
   #+(or CMU allegro)
   (:import-from "MOP"
    "CLASS-SLOTS"
    "SLOT-DEFINITION-NAME"
    "SLOT-DEFINITION-TYPE"
    "SLOT-DEFINITION-INITFORM")
   #+:LispWorks
   (:import-from "HCL"
    "CLASS-SLOTS"
    "SLOT-DEFINITION-NAME"
    "SLOT-DEFINITION-TYPE"
    "SLOT-DEFINITION-INITFORM")


   (:export
    "DECODE-XML-STRING"
    "ENCODE-XML-STRING"
    ;; classes
    "XML-SERIALIZER"
    "![CDATA["
    "!DOCTYPE"
    "!--"
    ;; aggregation methods
    "SET-ATTRIBUTE-VALUE"
    "ADD-SUBOBJECT"
    "PART-OF"
    "ADD-OBJECT-TO-SLOT"
    "cleanup-sub-object-slots"
    ;; print control methods
    "XML-PRINTABLE-AS-ATTRIBUTE-VALUE-P"
    "XML-PRINTABLE-AS-SUBELEMENT-P"
    "MAP-OBJECT PRINT-SLOT-WITH-NAME-P"
    "PRINT-SLOT-VALUE-AS-ATTRIBUTE"
    "PRINT-SLOT-NAME-VALUE-TYPE-AS-ATTRIBUTE"
    "PRINT-SLOT-VALUE-AS-SUBELEMENT PRINT-SLOTS"
    "PRINT-TYPED-ATTRIBUTE-VALUE"
    "PRINT-TYPED-SUBELEMENT-VALUE"
    "PRINT-DEFAULT-VALUE-ATTRIBUTES-P"
    "SLOT-NAME->ATTRIBUTE-NAME"
    ;; reading
    "LOAD-OBJECT"
    "SAVE-OBJECT"
    "FINISHED-READING"
    "FINISHED-READING-ATTRIBUTES"
    "READ-TYPED-ATTRIBUTE-VALUE"
    "READ-RETURN-VALUE"
    "WITHOUT-XML-READER"
    "ATTRIBUTE-NAME->SLOT-NAME"
    "FILE"
    ;; variables
    "DEF-ELEMENT-CLASS-NAME"
    "XML-TAG-NAME-STRING"
    ;; MOP
    "CLASS-SLOTS"
    "FIND-SLOT-DEFINITION"
    ;; MOP goodies
    "MOST-SPECIFIC-CLASS"
    ;; names
    "XML-TAG-NAME-SYMBOL"
    ;; variables
    "*XMLISP-PACKAGES*"
    "*FALLBACK-CLASS-NAME-FOR-ELEMENT-NAME-HOOK*"
    ;; types
    "PATH"
    "STRING-OR-NULL"
    "INTEGER-OR-NULL")

   (:shadow "BASE-CHAR-P"))



--------------
John Thingstad
From: Alessio Stalla
Subject: Re: Help with metaclass definitions
Date: 
Message-ID: <8b86f544-8036-4595-880a-a7a8d48ac632@j22g2000hsf.googlegroups.com>
Xmlisp is really cool. I used it in an attempt to write the nth Lisp
web framework (now abandoned for various reasons, though it was fun).
I remember I tweaked it to allow a kind of customization that wasn't
available (don't remember what), but never sent the patch to the
authors because I lost interest soon afterwards. As soon as I can get
the code, I can publish it if it's interesting enough.

----
Alessio Stalla


On Sep 17, 3:22 am, "John Thingstad" <·······@online.no> wrote:
> På Tue, 16 Sep 2008 17:49:04 +0200, skrev ······@corporate-world.lisp.de  
> <······@corporate-world.lisp.de>:
>
>
>
> > Alsohttp://www.agentsheets.com/lisp/XMLisp/
>
> To make it a bit more user friendly I changed to load as a ASDF library  
> and added a defpackage.
> Here is how:
>
> 1. Make a directory XMLisp
> 2. Copy XMLisp.lisp there (The 3.03 version)
> 3. Change (in-package :XML) to (in-package :XMLisp)
> 4. Remove (the deprecated) import and export statements
> 5. add the following files:
>
> XMLisp.asd
>
> (in-package :cl-user)
>
> (defpackage :XMLisp-asd
>    (:use :cl :asdf))
>
> (in-package :XMLisp-asd)
>
> (defsystem :XMLisp-sys
>    :serial t
>    :components ((:file "packages")
>                 (:file "XMLisp")))
>
> packages.lisp:
>
> (defpackage :XMLisp
>    ;; each MOP implementation appears to keep its symbols in a different,
>    ;; application specific package: how clever!!
>    ;; probably not a good idea to just USE that entire package
>    #+:mcl
>    (:import-from "CCL"
>     "SLOT-DEFINITION-NAME"
>     "SLOT-DEFINITION-TYPE"
>     "SLOT-DEFINITION-INITFORM")
>    #+(or :ccl-5.1 :openmcl)
>    (:import-from "CCL"
>     "CLASS-SLOTS")
>    #+:clisp
>    (:import-from "CLOS"
>     "CLASS-SLOTS"
>     "SLOT-DEFINITION-NAME"
>     "SLOT-DEFINITION-TYPE"
>     "SLOT-DEFINITION-INITFORM")
>    #+(or CMU allegro)
>    (:import-from "MOP"
>     "CLASS-SLOTS"
>     "SLOT-DEFINITION-NAME"
>     "SLOT-DEFINITION-TYPE"
>     "SLOT-DEFINITION-INITFORM")
>    #+:LispWorks
>    (:import-from "HCL"
>     "CLASS-SLOTS"
>     "SLOT-DEFINITION-NAME"
>     "SLOT-DEFINITION-TYPE"
>     "SLOT-DEFINITION-INITFORM")
>
>    (:export
>     "DECODE-XML-STRING"
>     "ENCODE-XML-STRING"
>     ;; classes
>     "XML-SERIALIZER"
>     "![CDATA["
>     "!DOCTYPE"
>     "!--"
>     ;; aggregation methods
>     "SET-ATTRIBUTE-VALUE"
>     "ADD-SUBOBJECT"
>     "PART-OF"
>     "ADD-OBJECT-TO-SLOT"
>     "cleanup-sub-object-slots"
>     ;; print control methods
>     "XML-PRINTABLE-AS-ATTRIBUTE-VALUE-P"
>     "XML-PRINTABLE-AS-SUBELEMENT-P"
>     "MAP-OBJECT PRINT-SLOT-WITH-NAME-P"
>     "PRINT-SLOT-VALUE-AS-ATTRIBUTE"
>     "PRINT-SLOT-NAME-VALUE-TYPE-AS-ATTRIBUTE"
>     "PRINT-SLOT-VALUE-AS-SUBELEMENT PRINT-SLOTS"
>     "PRINT-TYPED-ATTRIBUTE-VALUE"
>     "PRINT-TYPED-SUBELEMENT-VALUE"
>     "PRINT-DEFAULT-VALUE-ATTRIBUTES-P"
>     "SLOT-NAME->ATTRIBUTE-NAME"
>     ;; reading
>     "LOAD-OBJECT"
>     "SAVE-OBJECT"
>     "FINISHED-READING"
>     "FINISHED-READING-ATTRIBUTES"
>     "READ-TYPED-ATTRIBUTE-VALUE"
>     "READ-RETURN-VALUE"
>     "WITHOUT-XML-READER"
>     "ATTRIBUTE-NAME->SLOT-NAME"
>     "FILE"
>     ;; variables
>     "DEF-ELEMENT-CLASS-NAME"
>     "XML-TAG-NAME-STRING"
>     ;; MOP
>     "CLASS-SLOTS"
>     "FIND-SLOT-DEFINITION"
>     ;; MOP goodies
>     "MOST-SPECIFIC-CLASS"
>     ;; names
>     "XML-TAG-NAME-SYMBOL"
>     ;; variables
>     "*XMLISP-PACKAGES*"
>     "*FALLBACK-CLASS-NAME-FOR-ELEMENT-NAME-HOOK*"
>     ;; types
>     "PATH"
>     "STRING-OR-NULL"
>     "INTEGER-OR-NULL")
>
>    (:shadow "BASE-CHAR-P"))
>
> --------------
> John Thingstad
From: Madhu
Subject: xmlisp (was: Help with metaclass definitions)
Date: 
Message-ID: <m37i9abybr.fsf_-_@moon.robolove.meer.net>
* Alessio Stalla Wrote on Wed, 17 Sep 2008 02:20:42 -0700 (PDT):

| Xmlisp is really cool. I used it in an attempt to write the nth Lisp
| web framework (now abandoned for various reasons, though it was fun).
| I remember I tweaked it to allow a kind of customization that wasn't
| available (don't remember what), but never sent the patch to the
| authors because I lost interest soon afterwards. As soon as I can get
| the code, I can publish it if it's interesting enough.

What would also be cool is a library of freely available clos classes
based on xml-serializer for handling the various "standard" xml files.

It would be nice to have a place to collect xmlisp classes contributed
by users, [Just like everytime someone writes lisp ffi bindings to some
C library there is a new project on common-lisp.net] --- I think it
would be incredibly useful.

(Of course the problem is that that users should actually share their
 xmlisp classes to this library.  Myself, I'm too worried about the
 quality and correctness of my coverage for the xmlisp classes I've
 written, to cut configuration files and createrepo schemas, that I'd be
 afraid to submit them, but hey I'm just making suggestions :)

--
Madhu