Subject: Re: Newbie question: how to reorder descendants (e.g., footnotes) From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxx> Date: Thu, 09 Oct 1997 22:10:37 -0400 |
At 21:25 97/10/09 +0100, Aidan Killian wrote: > I am sure some of the more complex examples posted do some of this but >I find them somewhat impenetrable and crave a simpler example. > > A fragment of the DTD follows: > ><!ELEMENT genhdr - - (artinfo, tig, aug, abs, kwdg, cng, cg*) > > ><!ELEMENT artinfo - - (categ, crn, hst) > > ><!ELEMENT tig - - (sertl, atl) > > ><!ELEMENT (sertl | atl) - - (#pcdata | fn)+ > > > The required output order is and my probles are highlighted. > >crn, categ, tig, aug, kwdg, abs, hst, fn*, cng, cg* > ^^^ ^^^ I created a test with the above inputs and desired outputs patterning the program along your lines. I wrote a DSSSL program to put out an SGML instance with a different root element "NEW" but the output order as above. With these basics you should be able to modify your own program to your own needs. I'm assuming that you wanted the "hst" and "fn" elements removed from the parent elements in which they are found. After writing out the new file I parsed it with a DTD to your output order requirements to prove to myself that the result was what you wanted. The use of modes will accomplish what you want. In the following the default mode eats all footnotes and the use of a footnote processing mode spits them out. For the "hst" element I only process the children I want to at the time I want to, so a mode is necessary to have two element rules for the same element, one in the mode and one default. Note that the processing mode named '#f' is the unnamed processing mode (the set of element construction rules not within any mode). ............ Ken F:\FTEMP>type reseq.dsl <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN"> (define debug (external-procedure "UNREGISTERED::James Clark//Procedure::debug")) (declare-flow-object-class element "UNREGISTERED::James Clark//Flow Object Class::element") (declare-flow-object-class formatting-instruction "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") (root (sosofo-append (make formatting-instruction ;put out new DTD data: (string-append "<" "!DOCTYPE new [ <" "!ELEMENT new - O ( crn, categ, tig, aug, kwdg, abs, hst, fn*, cng, cg* )> <" "!ELEMENT tig - O ( sertl, atl )> <" "!ELEMENT ( crn, categ, sertl, atl, aug, kwdg, abs, hst, fn, cng, cg ) - O (#PCDATA)> ]> ")) (make element ;put out document element gi: "NEW" (process-children)))) (define (echo-element) (make element gi: (gi (current-node)))) (element genhdr (sosofo-append ;change order as required (process-matching-children "artinfo") ;regular handling (process-matching-children "tig") (process-matching-children "aug") (process-matching-children "kwdg") (process-matching-children "abs") ;special handling (with-mode only-hst (process-matching-children "artinfo")) (with-mode only-fn (process-matching-children "tig")) ;regular handling (process-matching-children "cng") (process-matching-children "cg"))) (element fn ;eat all fn elements not in special mode (empty-sosofo)) (element artinfo ;only put out what is desired (sosofo-append (process-matching-children "crn") (process-matching-children "categ"))) (mode only-hst ;only put out what is desired (element artinfo (with-mode #f (process-matching-children "hst")))) (mode only-fn ;only put out "fn" elements (element tig ;from all children (process-children)) (element sertl ;significant children (process-matching-children "fn")) (element atl ;significant children (process-matching-children "fn")) (element fn ;found what we are looking for (echo-element))) (default (echo-element)) ; end of file F:\FTEMP>type testin.sgm <!DOCTYPE genhdr [ <!ELEMENT genhdr - O (artinfo, tig, aug, abs, kwdg, cng, cg*) > <!ELEMENT artinfo - O (categ, crn, hst) > <!ELEMENT tig - O (sertl, atl) > <!ELEMENT (sertl | atl) - O (#pcdata | fn)+ > <!ELEMENT (aug,abs,kwdg,cng,cg,categ,crn,hst,fn) - O ( #pcdata )> ]> <genhdr> <artinfo> <categ>categ <crn>crn <hst>hst <tig> <sertl>sertl1-1,<fn>sertl1fn1</>sertl1-2,<fn>sertl1fn2</>sertl1-3 <atl>atl1-1,<fn>atl1fn1</>atl1-2,<fn>atl1fn2</>atl1-3 <aug>aug <abs>abs <kwdg>kwdg <cng>cng <cg>cg1 <cg>cg2 F:\FTEMP>nsgmls -s testin.sgm F:\FTEMP>jade -t sgml -c l:\jade\current\catalog -f test.err -d reseq.dsl testin.sgm >testout.sgm F:\FTEMP>type test.err F:\FTEMP>type testout.sgm <!DOCTYPE new [ <!ELEMENT new - O ( crn, categ, tig, aug, kwdg, abs, hst, fn*, cng, cg* )> <!ELEMENT tig - O ( sertl, atl )> <!ELEMENT ( crn, categ, sertl, atl, aug, kwdg, abs, hst, fn, cng, cg ) - O (#PCDATA)> ]> <NEW ><CRN >crn</CRN ><CATEG >categ</CATEG ><TIG ><SERTL >sertl1-1,sertl1-2,sertl1-3</SERTL ><ATL >atl1-1,atl1-2,atl1-3</ATL ></TIG ><AUG >aug</AUG ><KWDG >kwdg</KWDG ><ABS >abs</ABS ><HST >hst</HST ><FN >sertl1fn1</FN ><FN >sertl1fn2</FN ><FN >atl1fn1</FN ><FN >atl1fn2</FN ><CNG >cng</CNG ><CG >cg1</CG ><CG >cg2</CG ></NEW > F:\FTEMP>nsgmls -s testout.sgm F:\FTEMP> -- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com 1605 Mardick Court, Box 266, V: +1(613)489-0999 Kars, Ontario CANADA K0A-2E0 F: +1(613)489-0995 PGP Privacy: http://www.cyberus.ca/~holman/gkholman.pgp Training: http://www.CraneSoftwrights.com/schedule.htm DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Newbie question: how to reorder des, Aidan Killian | Thread | Course Syllabus, G. Ken Holman |
Newbie question: how to reorder des, Aidan Killian | Date | Course Syllabus, G. Ken Holman |
Month |