Thread View: comp.text.sgml
2 messages
2 total messages
Started by null
Fri, 06 Nov 1992 15:54
Data constraints
Author: null
Date: Fri, 06 Nov 1992 15:54
Date: Fri, 06 Nov 1992 15:54
26 lines
1192 bytes
1192 bytes
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.
I would like to be able to write something like :-
<!ELEMENT element - O ("Option1" | "Option2" | "Option3") >
Or use parameter reference entities to replace the text:-
<!ELEMENT element - O ( %option1; | %option2; | %option3;) >
<!ENTITY % option1 "Option1" >
<!ENTITY % option2 "Option2" >
<!ENTITY % option3 "Option3" >
Unfortunately these naive approaches don't work with the SGMLS parser
that we are using and I havn't been able to find the answer in the
ISO standard. Any ideas please?
Regards
Steve Hook
s.hook@mcs.surrey.ac.uk
Re: Data constraints
Author: drmacro
Date: Fri, 06 Nov 1992 17:35
Date: Fri, 06 Nov 1992 17:35
59 lines
2788 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads