Strong Typing in SGML and XML
Peter Newcomb
peter at techno.com
Tue May 6 21:33:10 BST 1997
> Date: Mon, 05 May 1997 17:09:21 -0700
> From: Tim Bray <tbray at textuality.com>
>
> Ever since about 15 minutes after SGML was born, database people have been
> discovering, to their surprise, that it contains no facilities for
> strong data typing. You can have an element named <BIRTH-DATE>, and
> SGML will have no problem accepting
>
> <birth-date>purple bananas rule</birth-date>.
It seems to me that this sort of data typing can already be
accomplished:
<!NOTATION SQL-DATE PUBLIC "...//NOTATION SQL DATE//EN">
<!ELEMENT birth-date - - (#PCDATA)>
<!ATTLIST birth-date
notation NOTATION (SQL-DATE) #FIXED SQL-DATE
>
Using data attributes, and HyTime's Data Attributes For Elements
(DAFE) facility (which acts as if the data content notation for an
element were an architectural form), one could implement a scheme like
the one you (Tim) propose:
<!NOTATION SQL-DATE PUBLIC "...//NOTATION SQL DATE//EN">
<!ATTLIST #NOTATION SQL-DATE
sql-min CDATA #IMPLIED
sql-max CDATA #IMPLIED
>
<!ELEMENT birth-date - - (#PCDATA)>
<!ATTLIST birth-date
sql-type NOTATION (SQL-DATE) #FIXED SQL-DATE
sql-min CDATA #FIXED "1900-01-01" -- some bogus restrictions --
sql-max CDATA #FIXED "1999-12-31"
>
Or better yet:
<!NOTATION SQL-DATATYPE PUBLIC "...//NOTATION SQL DATATYPE//EN">
<!ATTLIST #NOTATION SQL-DATATYPE
sql-type NAME #REQUIRED
sql-size NUMBER 0
sql-min CDATA #IMPLIED
sql-max CDATA #IMPLIED
>
<!ELEMENT birth-date - - (#PCDATA)>
<!ATTLIST birth-date
notation NOTATION (sql-datatype) #FIXED sql-datatype
sql-type NAME #FIXED sql-date
sql-min CDATA #FIXED "1900-01-01" -- some bogus restrictions --
sql-max CDATA #FIXED "1999-12-31"
>
Of course, both of these require data attributes, which XML does not
(yet!) support.
-peter
--
Peter Newcomb TechnoTeacher, Inc.
233 Spruce Avenue P.O. Box 23795
Rochester, NY 14611-4041 USA Rochester, New York 14692-3795 USA
+1 716 464 8696 (home) +1 716 464 8696 (direct)
+1 716 755 8698 (cell) +1 716 271 0796 (main)
+1 716 529 4304 (fax) +1 716 271 0129 (fax)
peter at petes-house.rochester.ny.us peter at techno.com
http://www.petes-house.rochester.ny.us http://www.techno.com
xml-dev: A list for W3C XML Developers
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To unsubscribe, send to majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
List coordinator, Henry Rzepa (rzepa at ic.ac.uk)
More information about the Xml-dev
mailing list