🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.sgml
Article #187

SGML-B -- compiled SGML?

#187
From: Dan Connolly
Date: Fri, 14 Aug 1992 06:56
77 lines
2703 bytes
What's the word on SGML-B? Does it exist? I think I want to use it.

I want to process SGML documents interactively, and parsing markup is a
batch mode thing to do.

Some "compiled" representation should allow me to navigate the document
quickly. I should be able to load the data and compute things like:

  what's the value of the SUBTITLE attribute of the element with id x123?

Here's a C++ description of what I have in mind:
The above example translates to
   SGML_document *doc = SGML_document::open_SGML_B(cin);
   SGML_TOKEN *n = doc->intern("SUBTITLE");
   SGML_TOKEN *id = doc->intern("x123");

   doc->idref(id).attributes().value(n);

class SGML_ATTLIST;
class SGML_TOKEN;
class SGML_GI;
class SGML_ELEMENT;
class SGML_data;

class SGML {
  SGML_ELEMENT& parent();
  int data(); // returns 1 if this is a character data element
  int rank(); // rank() == -1 for root
              // else parent().child(rank()) == this

  SGML_ELEMENT* idref(const SGML_TOKEN& id);
	// resolve idref within the document
};

class SGML_data : SGML {
public:
  size_t length();
  const char* string(); // C character array
};

class SGML_ELEMENT : SGML {
public:
  SGML_GI& gi();

  int children(); // 0 for empty
  SGML& child(int i); // for 0 <= i < children()
  SGML& child(int n, const SGML_GI& gi);
	// e.g. 4th paragraph child, 5th header child

  SGML& sibling(int n){
	return parent().child(rank()+n);
	};
  SGML* next() { return rank()<parent().children() ? &nth_sibling(1) : 0; };
  SGML* prev() { return rank()>0 ? &nth_sibling(-1) : 0; };

  SGML_ATTLIST attributes();
};

class SGML_document : SGML_ELEMENT {
public:
  static open_SGML_B(PositionableStream&);

  SGML_TOKEN intern(const char*);
}

class SGML_ATTLIST {
public:
  int qty();
  SGML_GI& name(int i); // for 0 <= i < qty()
  int index(cost SGML_GI& name);
  SGML_data value(int i);
  SGML_attribute attribute(const SGML_GI& gi);
};

class SGML_NAME {
  SGML_NAME(const char* from_string); // like interning a symbol in lisp
};
Technical Details
Message-ID: <1992Aug14.065625.26032@news.eng.convex.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!convex!convex!connolly

Show Full Headers
Complete Article Headers
Newsgroups: comp.text.sgml
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!convex!convex!connolly
From: connolly@convex.com (Dan Connolly)
Subject: SGML-B -- compiled SGML?
Sender: usenet@news.eng.convex.com (news access account)
Message-ID: <1992Aug14.065625.26032@news.eng.convex.com>
Date: Fri, 14 Aug 1992 06:56:25 GMT
Nntp-Posting-Host: pixel.convex.com
Organization: Engineering, CONVEX Computer Corp., Richardson, Tx., USA
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.
Lines: 78