SGML

Rank Examples

rank/rank0 rank/rank1 rank/rank2 rank/rank4
Examples for using ranked elements
rank/rank5

If FEATURES MINIMIZE RANK NO is specified in the SGML declaration (or is implied by context, such as when processing an XML rather than full SGML file, where ranked elements aren't supported), declaring a ranked element is treated as error

rank/rank0

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h1>Heading 1</h1>
<p>Paragraph 1</p>
<h2>Heading 1.1</h2>
<p>Paragraph 1.1</p>
<h3>Heading 1.1.1</h3>
<p>Paragraph 1.1.1</p>
</test>

Result

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h1>Heading 1</h1>
<p1>Paragraph 1</p>
<h2>Heading 1.1</h2>
<p2>Paragraph 1.1</p>
<h3>Heading 1.1.1</h3>
<p3>Paragraph 1.1.1</p>
</test>

rank/rank1

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h2>Heading 1</h2>
<p>Paragraph 1</p>
<h>Heading 1.1</h>
</test>

Result

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h2>Heading 1</h2>
<p2>Paragraph 1</p>
<h2>Heading 1.1</h>
</test>

rank/rank2

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h>Heading 1</h>
<p>Paragraph 1</p>
</test>

Result


"rank2.sgm": line 8: fatal: 'h': omitting rank when no current rank is established

rank/rank4

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h2>Heading</h2>
<h4>Subheading</h4>
</test>

Result


"rank4.sgm": line 9: fatal: 'h4': undeclared rank

rank/rank5

<!DOCTYPE test [
	<!ELEMENT test - - ((h1|h2|h3|p1|p2|p3)+)>
	<!ELEMENT (h|p) 1 - - (#PCDATA)>
	<!ELEMENT (h|p) 2 - - (#PCDATA)>
	<!ELEMENT (h|p) 3 - - (#PCDATA)>
]>
<test>
<h2>Heading 1</h2>
</test>

Result


"rank5.sgm": line 3: fatal: '1 - - (#'...: invalid model group specification