SGML

Declared Content Examples

declared-content/any1 declared-content/any2 declared-content/any3

Basic examples for declared content ANY

declared-content/any5

Elements declared ANY can be opened as contextually required elements in omitted tag inference

declared-content/any6

Parsed character data is permitted as content of declared-ANY elements

declared-content/any7

Like in elements having content models, when occuring in a context where an omitted tag for an element declared ANY is inferred, only the portion starting at the first non-whitespace character is considered child content character data of the inferred element

declared-content/any8

Exclusion exceptions can be declared on declared-ANY elements, allowing to restrict the set of elements that can appear in child content

declared-content/any10

When FEATURES MININMIZE IMPLYDEF ELEMENT YES is specified in the SGML declaration (which it is by default with sgmljs.net SGML), then undeclared elements may occur in declared ANY content

declared-content/cdata0

Basic CDATA-declared element example

declared-content/cdata4

Named entity references aren't replaced by their respective replacement text in CDATA-declared content

declared-content/cdata2

When closing definitely completed elements, end-element tags for CDATA-declared elements can be inferred as long as they are declared omittable

On the other hand, CDATA-declared elements aren't considered when opening contextually required elements during inference of omitted start-element tags

declared-content/cdata3

Vharacter data content for CDATA-declared elements can be empty

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.

declared-content/any1

<!DOCTYPE test [
	<!ELEMENT test - - ANY>
	<!ELEMENT a - - (#PCDATA)>
	<!ELEMENT b - - (c, d)>
	<!ELEMENT c - - (#PCDATA)>
	<!ELEMENT d - - (#PCDATA)>
]>
<test><a></a><b><c></c><d></d></b></test>

declared-content/any2

<!DOCTYPE test [
	<!ELEMENT test - - ANY>
	<!ELEMENT a - - (#PCDATA)>
	<!ELEMENT b - - (c, d)>
	<!ELEMENT c - - (#PCDATA)>
]>
<test><a></a><b><c></c><d></d></b></test>

declared-content/any3

<!DOCTYPE test [
	<!ELEMENT test - - (a, b)>
	<!ELEMENT a - - ANY>
	<!ELEMENT b - - (#PCDATA)>
	<!ELEMENT c - - (d+, e)>
	<!ELEMENT d - - (#PCDATA)>
	<!ELEMENT e - - (#PCDATA)>
]>
<test><a><b></b><c><d></d><d></d><e></e></c></a><b></b></test>

declared-content/any5

<!DOCTYPE test [
	<!ELEMENT test - - (a, b)>
	<!ELEMENT a - - (#PCDATA)>
	<!ELEMENT b O O ANY>
	<!ELEMENT c - - (d+, e)>
	<!ELEMENT d - - (#PCDATA)>
	<!ELEMENT e - - (#PCDATA)>
]>
<test><a></a><c><d></d><e></e></c></test>

declared-content/any6

<!DOCTYPE test [
	<!ELEMENT test - - (a)>
	<!ELEMENT a - - ANY>
	<!ELEMENT b - - (#PCDATA)>
]>
<test><a> chardata in <b>mixed</b> content</a></test>

declared-content/any7

<!DOCTYPE test [
	<!ELEMENT test - - (a,b)>
	<!ELEMENT a O O ANY>
	<!ELEMENT b - - (#PCDATA)>
]>
<test>
	chardata in <b>mixed</b></a>
<b>content, cf split-pcdata-test0</b>
</test>

declared-content/any8

<!DOCTYPE test [
	<!ELEMENT test - - (a, b)>
	<!ELEMENT a - - ANY -(b)>
	<!ELEMENT b - - (#PCDATA)>
	<!ELEMENT x - - (#PCDATA)>
]>
<test><a><x></x></a><b></b></test>

declared-content/any10

<!DOCTYPE test [
	<!ELEMENT test - - (a, b)>
	<!ELEMENT a - - ANY -(b)>
	<!ELEMENT b - - (#PCDATA)>
	<!ELEMENT x - - (#PCDATA)>
]>
<test><a><y></y></a><b></b></test>

declared-content/cdata0

<!DOCTYPE test [
	<!ELEMENT test - - (a)>
	<!ELEMENT a - - CDATA>
]>
<test><a> chardata </a></test>

declared-content/cdata4

<!DOCTYPE test [
	<!ELEMENT test - - (a)>
	<!ELEMENT a - - CDATA>
	<!ENTITY e "bla">
]>
<test><a>&e;</a></test>

declared-content/cdata2

<!DOCTYPE test [
	<!ELEMENT test - - (a)>
	<!ELEMENT a - O CDATA>
]>
<test><a> chardata </test>

declared-content/cdata3

<!DOCTYPE test [
	<!ELEMENT test - - (a)>
	<!ELEMENT a - - CDATA>
]>
<test><a></a></test>