DD: legal numbering, the idiots guide.

Subject: DD: legal numbering, the idiots guide.
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Thu, 2 Apr 1998 16:21:42 +0100
Legal numbering - idiot fashion.
This gives the idiot version of that offered by Richard Light,
who takes care of unwanted siblings and trawls the hierarchy 
properly. 
This does work for a straightforward case.


Caveats:
1. The lower level numbered elements must have an
	adequacy of 'grandparents' prior to meeting the root of the
	document.
2. Assumes that the text needing numbering is one level below
   the multiply defined element (section, subsection etc)
   The example uses the head element for this.


For a DTD with a regular structure such as


<!ELEMENT section  - - (head ,   intro? , (
               (%para-sequence;) | subsection  )+) >

<!ELEMENT subsection  - - (head , intro? , (
               (%para-sequence;) | subsubsection )+) >
			   
<!ELEMENT subsubsection  - - (head , (%para-sequence;)) >

<!ELEMENT head  - - ((#PCDATA) | i | acronym)+ >

the numbering can be achieved as follows:
;
;  The highest numbered levels are followed by a period and space.
;
(element (section head)
	(make paragraph
	use: %header-style%     ; your own definition
	(make sequence
	 (literal (format-number 
		     (child-number 
                       (parent (current-node)))
                        "1" ))
	 (literal ".  ")
   	 (process-children))))
	 
	 
;
; The next level down has both the integer and first decimal part.
;
(element (topic1 head) 
	(make paragraph
	  use: topic-style
	space-before: (* %bf-size% 1.2)
	space-after: (* %bf-size% 1.2)
	start-indent: 0.5in
	font-size:  %bf-size% 
	(make sequence
;    ^^^^^^^
	(literal (format-number 
		     (child-number 
                       (parent (parent (current-node))))
                        "1" )) ; number the parent
	(literal ".")				; period separator
;
;  Now deal with this element
;
	(literal (format-number 
		     (child-number 
                       (parent (current-node)))
                        "1" ))  ; number this element
	(literal " ")			    ; Trailing space.
	(process-children))))       ; finally output the content.
	
; More levels should be inserted ^^^ using
;  (parent (parent (parent (current-node))))
;   so long as the hierarchy stretches to it!


Hope this isn't too low level?
regards, DaveP


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread