re: (dsssl) Modification of the hierarchy

Subject: re: (dsssl) Modification of the hierarchy
From: Markus.Reinsch@xxxxxxxxxxxxxx
Date: Wed, 25 Jul 2001 10:00:29 +0200
Hi Jany

I see 2 solutions:

1. the solution you suggested. Perhaps you can use my algorithm below.
   This solutions is quite slow on large documents.
   You have to extend the algorithm to 2 levels.
   The tokenizer is working just on one level.

(define (tokenizer sl)
  (cond ((node-list-empty? sl)
	(list))
	((separator? sl)
	 (cons (list (node-list-first sl)) (tokenizer (node-list-rest sl))))
	((node-list-empty? (node-list-rest sl))
	 (list (list (node-list-first sl))))
	((separator? (node-list-rest sl))
	 (cons (list (node-list-first sl) (node-list-second sl)) (tokenizer
(node-list-rest (node-list-rest sl)))))
	(else (add-on (node-list-first sl) (tokenizer (node-list-rest
sl))))))

(define (node-list-second nd)
  (node-list-first (node-list-rest nd)))

(define (add-on chr li)
  (if (null? li)
      (list (list chr))
      (cons (cons chr (car li)) (cdr li))))

2. A hack: You insert tags as text in the according positions, i.e.
   when you start the next level you call (make-tag "para level=2")
   This solution is faster but its just a hack and you could use perl as
well ;-)

 (define (make-tag gi)
   (sosofo-append
    (make formatting-instruction data: "<") (literal gi)
    (make formatting-instruction data: ">")))

Markus

>make "trees"
>from "flat" elements.
>What I have is
><division>
>  <para Level="1">
>  <para Level="2">
>  <list Level="3">
>  <list Level="3">
>  <list Level="2">
>So, each element following an element with a higher Level (in 
>this case,
>higher means less, sorry) is a sub element of the preceding.
>
>And I want
><division>
>  <para Level="1">
>    <para Level="2">
>      <list Level="3">
>      <list Level="3">
>    <list Level="2">
>So, I suppose the way to go is :
>- - select the children of the divison to build an input node-list.
>- - build a list of list of node-lists matching the structure 
>of the tree
>- - process this list

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

Current Thread