SGML

Marked Section Examples

marked-sections/marked-section4 marked-sections/marked-section6
Basic example for marked sections used in content
marked-sections/marked-section7

Basic example for a RCDATA marked section; the RCDATA keyword is expanded from the rc parameter entity; an RCDATA marked section gets serialized as CDATA marked section in the output

marked-sections/marked-section8

An omitted keyword in a marked section, or an entity reference that expands to an empty or blank character sequence, is treated as if INCLUDE was specified as keyword

marked-sections/marked-section9

If both IGNORE and INCLUDE are specified as keyword, then IGNORE takes precedence

marked-sections/marked-section1

Shows a corner case where the keyword for the inner marked section is CDATA such that the content of that marked section is escaped and handled as parsed character data; the document is rejected because characer data isn't accepted as content of the test element

marked-sections/marked-section-in-prolog1 marked-sections/marked-section-in-prolog2

Basic example for marked sections used in the document prolog; the document instance in the second example is rejected, because the declaration for the test element document, contained an an IGNORE marked section, isn't processed

marked-sections/marked-section-in-prolog3 marked-sections/marked-section-in-prolog4

Example for nested marked sections used in the document prolog; like in the previous examples, the declaration for the test element isn't processed in the second case

marked-sections/marked-section-in-prolog3 marked-sections/marked-section-in-prolog4
Example for doubly-nested marked sections used in the document prolog
marked-sections/marked-section-in-prolog0 marked-sections/marked-section-in-prolog5 marked-sections/marked-section-in-prolog8
Marked sections can only be used in a context where a parameter entity can be defined (ie. cannot be used outside the document prolog or outside content)
marked-sections/marked-section12
Example for an unrecognized marked section keyword
marked-sections/marked-section3

Verbatim text recognized as marked section delimiter (the character sequence ]]>) must be escaped (eg. using character entity reference) in content

marked-sections/marked-section4

<!DOCTYPE test [
	<!ELEMENT test - - (#PCDATA|bla)*>
	<!ELEMENT bla - - (#PCDATA)>
]>
<test><![ INCLUDE[<bla></bla><bla></bla>text<bla></bla>]]></test>

Result

<!DOCTYPE test [
	<!ELEMENT test - - (#PCDATA|bla)*>
	<!ELEMENT bla - - (#PCDATA)>
]>
<test><bla></bla><bla></bla>text<bla></bla></test>

marked-sections/marked-section6

<!DOCTYPE test [
	<!ELEMENT test - - (#PCDATA|bla)*>
	<!ELEMENT bla - - (#PCDATA)>
]>
<test><![ IGNORE[<bla></bla><bla></bla>text<bla></bla>]]></test>

Result

<!DOCTYPE test [
	<!ELEMENT test - - (#PCDATA|bla)*>
	<!ELEMENT bla - - (#PCDATA)>
]>
<test></test>

marked-sections/marked-section7

<!DOCTYPE test [
	<!ENTITY % rc "RCDATA">
	<!ENTITY someent "hello">
	<!ELEMENT test - - (#PCDATA)>
]>
<test><![%rc;[&someent;, world!]]></test>

Result

<!DOCTYPE test [
	<!ENTITY % rc "RCDATA">
	<!ENTITY someent "hello">
	<!ELEMENT test - - (#PCDATA)>
]>
<test><![CDATA[hello, world!]]></test>

marked-sections/marked-section8

<!DOCTYPE test [
	<!ENTITY someent "hello">
	<!ELEMENT test - - (#PCDATA)>
]>
<test><![ [&someent;, world!]]></test>

Result

<!DOCTYPE test [
	<!ENTITY someent "hello">
	<!ELEMENT test - - (#PCDATA)>
]>
<test>hello, world!</test>

marked-sections/marked-section9

<!DOCTYPE test [
	<!ENTITY someent "hello">
	<!ELEMENT test - - (#PCDATA)>
]>
<test><![IGNORE INCLUDE [&someent;, world!]]></test>

Result

<!DOCTYPE test [
	<!ENTITY someent "hello">
	<!ELEMENT test - - (#PCDATA)>
]>
<test></test>

marked-sections/marked-section1

<!DOCTYPE test [
	<!ELEMENT test - - (sub*)>
	<!ELEMENT sub - - (#PCDATA)>
	<!ENTITY % keyword "INCLUDE">
	<!ENTITY % incl "CDATA">
]>
<test>
<![ %keyword;[
	<![ %incl;[
		<sub></sub>
	]]>
]]>
</test>

Result


"marked-section1.sgm": line 9: fatal: '
		&#60;': unexpected character data

marked-sections/marked-section-in-prolog1

<!DOCTYPE test [
	<![INCLUDE[
		<!ELEMENT test - - (#PCDATA)>
	]]>
]>
<test></test>

Result

<!DOCTYPE test [
	<![INCLUDE[
		<!ELEMENT test - - (#PCDATA)>
	]]>
]>
<test></test>

marked-sections/marked-section-in-prolog2

<!DOCTYPE test [
	<![IGNORE[
		<!ELEMENT test - - (#PCDATA)>
	]]>
]>
<test></test>

Result


"marked-section-in-prolog2.sgm": line 6: fatal: 'test': undeclared element type and IMPLYDEF ELEMENT NO specified

marked-sections/marked-section-in-prolog3

<!DOCTYPE test [
	<![INCLUDE[
		<!ENTITY % incl "INCLUDE">
		<![%incl;[
			<!ELEMENT test - - (#PCDATA)>
		]]>
	]]>
]>
<test></test>

Result

<!DOCTYPE test [
	<![INCLUDE[
		<!ENTITY % incl "INCLUDE">
		<![%incl;[
			<!ELEMENT test - - (#PCDATA)>
		]]>
	]]>
]>
<test></test>

marked-sections/marked-section-in-prolog4

<!DOCTYPE test [
	<![INCLUDE[
		<!ENTITY % incl "IGNORE">
		<![%incl;[
			<!ELEMENT test - - (#PCDATA)>
		]]>
	]]>
]>
<test></test>

Result


"marked-section-in-prolog4.sgm": line 9: fatal: 'test': undeclared element type and IMPLYDEF ELEMENT NO specified

marked-sections/marked-section-in-prolog3

<!DOCTYPE test [
	<![INCLUDE[
		<!ENTITY % incl "INCLUDE">
		<![%incl;[
			<!ELEMENT test - - (#PCDATA)>
		]]>
	]]>
]>
<test></test>

Result

<!DOCTYPE test [
	<![INCLUDE[
		<!ENTITY % incl "INCLUDE">
		<![%incl;[
			<!ELEMENT test - - (#PCDATA)>
		]]>
	]]>
]>
<test></test>

marked-sections/marked-section-in-prolog4

<!DOCTYPE test [
	<![INCLUDE[
		<!ENTITY % incl "IGNORE">
		<![%incl;[
			<!ELEMENT test - - (#PCDATA)>
		]]>
	]]>
]>
<test></test>

Result


"marked-section-in-prolog4.sgm": line 9: fatal: 'test': undeclared element type and IMPLYDEF ELEMENT NO specified

marked-sections/marked-section-in-prolog0

<![INCLUDE[
<!DOCTYPE test [
	<!ELEMENT test - - (#PCDATA)>
]>
]]>
<test></test>

Result


"marked-section-in-prolog0.sgm": line 1: fatal: content must start with document element when document type isn't specified

marked-sections/marked-section-in-prolog5

<!DOCTYPE test [
			<!ELEMENT test - - (#PCDATA)>
]>
<![INCLUDE[
	<!DOCTYPE other [
		<!ENTITY % incl "IGNORE">
		<![%incl;[
			<!ELEMENT other - - (#PCDATA)>
		]]>
	]>
]]>
<test></test>

Result


"marked-section-in-prolog5.sgm": line 5: fatal: document type declaration outside document prolog

marked-sections/marked-section-in-prolog8

<!DOCTYPE test [
	<!ENTITY % other "[ <!ELEMENT other - - (#PCDATA)> ]">
	<!ELEMENT test - - (#PCDATA)>
]>
<!DOCTYPE other %subset;> 
<test></test>

Result


"marked-section-in-prolog8.sgm": line 5: fatal: '%subset;...': invalid external identifier specification

marked-sections/marked-section12

<!doctype test [
	<!element test - - (#pcdata)>
	<!entity % keyword "invalid">
]>
<test><![ %keyword; [ blabla ]]></test>

Result


"marked-section12.sgm": line 5: fatal: '<![ %key': unrecognized marked section keyword(s)

marked-sections/marked-section3

<!DOCTYPE test [
	<!ELEMENT test - - (#PCDATA)>
]>
<test>marked section end: ]]></test>

Result


"marked-section3.sgm": line 4: fatal: unexpected marked section end