🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.sgml
Article #379

Re: Data constraints

#379
From: drmacro
Date: Fri, 06 Nov 1992 17:35
59 lines
2788 bytes
In <1992Nov6.155434.24122@EE.Surrey.Ac.UK> Steve Hook writes:

>Newcomer to SGML seeks assitance,

>We are trying to define an element which may occur in text as one of a set
>of allowed character strings. That is a kind of PCDATA item constrained to
>be a member of a certain set of values.
>s.hook@mcs.surrey.ac.uk

SGML provides no way to constrain the values of PCDATA, however,
HyTime (ISO 10744) does, with the HyLex function.  (Of course,
your parser or application has to support HyLex, but we'll assume
it does for argument).  HyLex is an extension of the SGML
content model notation that allows literals and the use of
"lexical type names" defined elsewhere (either in the HyTime
standard or in the definition of your application, for example,
in an SGML-encoded style definition document).

For the designs I've been working on, I've defined a LEXMODEL=
attribute that defines the lexical rules for one or more attributes
and/or the element content, something like this:

<!-- Note:  in the lexmodel, '<'and '>' are really square brackets -->
<!ELEMENT  zipcode  - - (#PCDATA) -- Contains a zip code -->
<!ATTLIST  zipcode
             LexModel CDATA #FIXED
                   "#CONTENT (<0-9>, <0-9>, <0-9>, <0-9>, <0-9>,
                              ("-", <0-9>, <0-9>, <0-9>, <0-9>)?)"
--
  US ZIP code is a 5-digit number optionally followed by a 4-digit
  number separated by a dash.
--
>

The HyLex definition of LEXMODEL is:

<HyLex fn=lexmodelatt>
(("#CONTENT" | attname), lexmodel)+
</HyLex>
<HyLex fn=lexmodel>
LexicalTypeName | ("(", HyLexExpr, ")")
</HyLex>

In other words, one or more attribute name/lexmodel pairs,
with the reservered name "#CONTENT" letting you define
the rules for the element content.

I'm not sure the HyTime standard actually defines the LexModel=
attribute, at least as I've used it here, but it doesn't need to for
me to be able to define its use in my application.  I'm sure any
parser vendor could add generic HyLex support to their product without
any great difficulty.  They may already have the base for it in some
proprietary way.

Eliot Kimber                      Internet:  drmacro@ralvm13.vnet.ibm.com
Dept E14/B500                     IBMMAIL:   USIB2DK9@IBMMAIL
Network Programs Information Development     Phone: 1-919-543-7091
IBM Corporation
Research Triangle Park, NC 27709
Technical Details
Message-ID: <19921106.093608.924@almaden.ibm.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!ralvm13.VNET.IBM.COM
References: <1992Nov6.155434.24122@EE.Surrey.Ac.UK>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ralvm13.VNET.IBM.COM
From: drmacro@ralvm13.VNET.IBM.COM
Message-ID: <19921106.093608.924@almaden.ibm.com>
Date: Fri, 6 Nov 92 12:35:45 EST
Newsgroups: comp.text.sgml
Subject: Re: Data constraints
Disclaimer: This posting represents the poster's views, not those of IBM
News-Software: UReply 3.0
References: <1992Nov6.155434.24122@EE.Surrey.Ac.UK>
Lines: 60