NON-DELIVERY of: object oriented data models and client side CGI

MMcLay ([email protected])
Fri, 17 Jun 1994 13:11 -0500 (EST)


Intended recpient(s): Steve Browne @ ZD Europe
Failure reason: Error transferring to CERES MAIL.BOX; You are not authorized to perform that operation
O-CMS-ErrorsTo: listmas @ INTERNET (listmaster) {[email protected]}
Carola Wittigschlager writes:
> For my dissertation I need an object-oriented data modell for
> HTML-documents.
> Do you know, where I can get this?

I'm not aware of any existing object-oriented data models for
HTML-documents. There was a short discussion on the
convergence of HTTP and object oriented systems in
http://info.cern.ch/hypertext/WWW/Bugs/Objects.html.

The "Reform of SGML" suggested by Tim Berners-Lee, which appears in
http://info.cern.ch/hypertext/WWW/MarkUp/SGML/TimComments.html, may
also be of interest. This note suggested some possible changes to
the SGML syntax. Starting with this idea, you might want to
investigate replacing the SGML markup with Python object constructors
as a means of defining your object-oriented data model of HTML.

There's a short example attached that illustrates nine HTML elements
(P, Header, H1, Title, A, Dl, Dd, Dt, and B) coded as Python classes
and a second example that uses these classes to markup a document
using Python constructors. A couple of the elements don't print out
yet, but the linemode() method does mimic the output of the line mode
browser for some of the elements. The program uses multiline strings
so be sure to use Python version 1.0.2.

Given this example, it seems reasonable that Python might be a good
choice for a client side CGI scripting language for WWW. WWW
applications could be extended to accept the Python by embedding the
Python interpreter as an alternative document input parser. Python
aware applications could then read documents written in either the
HTML or in the Python .py file format and the Python .pyc format. (The
.pyc format is a byte compiled version of the .py files.)

Documents written in Python could incorporate active elements that
would be executed in an isolated environment on the client side. This
would allow domain specific functions to be included in a document,
such range checking of form input fields. This could also facilitate
the ability to redefine of the markup language on the fly by making a
collection of client display widgets available that could be used by
Python class definitions of elements to display the content of the
document.

Michael J. McLay
National Institute of Standards and Technology
Bld 220 Rm A357 (office), Bld 220 Rm B344 (mail)
Gaithersburg, Maryland 20899, (301)975-4099

#-----------------------------phd.py --------------------------------------
# Python Hypertext Document Definitions Version 0.1
import string
class DocType:
def __init__(self,version,list):
self. list = list
def linemode (self):
for i in self.list: i.linemode()
class P:
def __init__(self,l):
self. list = l
# self.linemode()
def linemode (self):
try:
for i in self.list: i.linemode()
except TypeError,x:
print i+'\n'
class Head:
def __init__(self,l):
self. list = l
def linemode (self):
for i in self.list: i.linemode()

class H1:
def __init__(self,s):
self. string = s
def linemode (self):
print string.upper(self.string)+'\n'
class Title:
def __init__(self,s):
self. string = s
def linemode (self):
print string.center (string.upper(self.string),80)+'\n'
class A:
href = 1
name = 2
def __init__(self,s,l):
self. list = l
def linemode (self):
for i in self.list:
try:
for i in self.list: i.linemode()
except TypeError,x:
print i+'[##]',
class Dl:
def __init__(self,l):
self. list = l
def linemode (self):
for i in self.list: i.linemode()
class Dd:
def __init__(self,l):
self. list = l
def linemode (self):
for i in self.list:
try:
for i in self.list: i.linemode()
except TypeError,x:
print " ",i
class Dt:
def __init__(self,l):
self. list = l
def linemode (self):
for i in self.list: i.linemode()
class B:
def __init__(self,l):
self. list = l
def linemode (self):
for i in self.list: print "**",i,"**"

#------------------------example.phd.py------------------------------------
# this is an example .phd file (Python Hypertext Document)
# This is an executable document file written in the Python Language

from phd import *

demodoc = DocType ("PHL Version 0.1",[

Head ( [ Title ("This is an example of a Title")] ),

H1 ("Here is an H1"),

P([

"""I've been experimenting with recoding World Wide Web HTML documents
using the Python language. Some interesting possibilities would be
available if HTML interpreters started by first converting to Python.
Documents could be turned into binary objects by compling the python
code. Rather than sending the doc.py file over the wire, the doc.pyc
file could be sent."""]),

P ([

"""My Python interpreter is very simplistic at this time. I do not
automatically reformat paragraphs. Instead, I rely on the python
multi-line string and manually reformat the source text in an editor.
A general formater class is needed to perform this function. """,

A ({A.href:"http://www.doc.gov/"}, [
"This phrase is highlighted as an anchor"]),
"and",
A({A.href:"http://www.doc.gov/"}, ["so is this one"]),
".",
]),

P([

"""Here's a second long paragraph. It's included just to fill up some
space in this example. The demonstration P class should call a
reformater class to format the paragraphs."""

]),
P([ "This third paragraph includes another ",
A ({A.href:"http://www.eeel.nist.gov/nist/WWWtasks.html"},
["anchored phrase"]), "and an anchore name.",
A({A.name:"FAQ"},[])
]),

H1( "Here are some problems with this concept" ),

Dl([
Dt([B([ "Difficult to visually parse"])]),
Dd(["End tags do not stick out because they are generic punctuation"]),
Dt([B([ "Parse errors hard to detect"])]),
Dd(["Everything is in one line"]),
Dt([B([ "Anchors aren't working yet"])]),
Dd([A({A.href:"http://edison.eeel.nist.gov/nist/writingforWWW.html"},
["Anchor"]), "are just for show. This is a temporary problem that
could be made to work. "])
])
])

demodoc.linemode()