SGML

Declared Content Examples

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

Basic examples for declared content ANY

declared-content/any4

Child elements used in the content for an element declared ANY are validated according to their respective content declaration (unless declared ANY themselves)

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 declared-content/any9

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 (or implied from context such as when processing a markdown file), then undeclared elements may occur in declared ANY content

declared-content/any11

Otherwise, it's an error to use an undeclared element 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; TODO: FIXME: needs editiings after implemented escaping/wrapping into CDATA sections in an HTML output context or wherever no DTD is serialzed

declared-content/cdata1

CDATA-declared elements aren't considered when opening contextually required elements during inference of omitted start-element tags

declared-content/cdata2

On the other hand, when closing definitely completed elements, end-element tags for CDATA-declared elements can be inferred, when declared omittable

declared-content/cdata3

Character data content for CDATA-declared can be omitted/empty

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>

Result

<!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>

Result


"any2.sgm": line 7: fatal: 'd': undeclared element type and IMPLYDEF ELEMENT NO specified

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>

Result

<!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/any4

<!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></c></a><b></b></test>

Result


"any4.sgm": line 9: fatal: 'c': unexpected end of content model

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>

Result

<!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><b><c><d></d><e></e></c></b></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>

Result

<!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>

Result

<!DOCTYPE test [
	<!ELEMENT test - - (a,b)>
	<!ELEMENT a O O ANY>
	<!ELEMENT b - - (#PCDATA)>
]>
<test>
	<a>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>

Result

<!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/any9

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

Result


"any9.sgm": line 7: fatal: 'test': end-tag omission not allowed at <a>

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>

Result

<!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/any11

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

Result


"any11.sgm": line 7: fatal: 'y': undeclared element type and IMPLYDEF ELEMENT NO specified

declared-content/cdata0

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

Result

<!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>

Result

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

declared-content/cdata1

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

Result


"cdata1.sgm": line 5: fatal: character data not accepted here and can't omit start-tag for element 'a' with declared content

declared-content/cdata2

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

Result

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

declared-content/cdata3

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

Result

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