SGML

Data Entities Examples

data-entities/datatext1
Basic test showing that eg. STAGO delimiters get escaped in data text entities
data-entities/datatext2
General entity references/ERO characters in data text entities are ignored
data-entities/datatext3

OTOH, parameter entity references in data text entities do get expanded

data-entities/datatext4
References to undeclared parameter entities in data text entities get flagged as errors and expanded into the empty string
data-entities/extdatatext1

The syntax for declaring external general data entities requires using a notations; references to data text entities don't get expanded by SP but reproduced as-is in the output (arguably this is bogus, since when using the sgmlnorm program which doesn't output the DTD we'll end up with invalid/non-reparseable output); $productname, OTOH, does expand CDATA and SDATA data entities (but not NDATA entities); moreover, any result document produced by $productname will always contain a DTD

data-entities/extdatatext2

SDATA is treated like CDATA when used in data entity declarations

Note: To process SGML from the example sources, copy and paste an example source, store it into a file with the ".sgm" file extension, and invoke
sgmlproc <your-file.sgm>
where <your-file.sgm> is replaced by the actual file used for storing.

data-entities/datatext1

<!doctype test [
	<!element test - - (#pcdata)>
	<!entity ent cdata "text with escaped <> delimiters">
]>
<test>&ent</test>

data-entities/datatext2

<!doctype test [
	<!element test - - (#pcdata)>
	<!entity refdent cdata "text containing what looks like an &entity reference">
	<!entity ent cdata "text with escaped <> delimiters and unexpanded &refdent entity references">
]>
<test>&ent</test>

data-entities/datatext3

<!doctype test [
	<!element test - - (#pcdata)>
	<!entity % refdent "parameter entity replacement text">
	<!entity ent cdata "text with escaped <> delimiters and expanded %refdent parameter entity reference">
]>
<test>&ent</test>

data-entities/datatext4

<!doctype test [
	<!element test - - (#pcdata)>
	<!entity ent cdata "text with escaped <> delimiters and expanded %refdent parameter entity reference">
]>
<test>&ent</test>

data-entities/extdatatext1

<!doctype test [
	<!element test - - (#pcdata)>
	<!notation n system "somenotation">
	<!entity ent system "extdatatext1.txt" cdata n>
]>
<test>&ent</test>

data-entities/extdatatext2

<!doctype test [
	<!element test - - (#pcdata)>
	<!notation n system "somenotation">
	<!entity ent system "extdatatext1.txt" sdata n>
]>
<test>&ent</test>