Hi Alex,
(in file
(pipe (while (and (echo !--) (from --)))
(xml) ) )
I fact, I would like to remove that half-hearted comment feature from
lib/xml.l. Does anybody have objections?
since the XML declaration is optional, I would need to write:
(or (in F (pipe (while (and (echo !--) (from --)))
(and (xml?) (xml
(in F (pipe (while (and (echo !--) (from --)))
(xml
to load xml data.
Would not it be better if the xml function simply handled it all, the
xml declaration, comments and xml elements? It looks like the current
code is not far from it.
The following code handles optional declarations and comments (both
inside and outside the root element):
(de xml2 (Lst N)
(if Lst
(let Tag (pop 'Lst)
(space (default N 0))
(prin Tag)
(for X (pop 'Lst)
(prin (car X) =\)
(escXml (cdr X))
(prin \) )
(nond
(Lst (prinl /))
((or (cdr Lst) (pair (car Lst)))
(prin )
(escXml (car Lst))
(prinl / Tag ) )
(NIL
(prinl )
(for X Lst
(if (pair X)
(xml X (+ 3 N))
(space (+ 3 N))
(escXml X)
(prinl) ) )
(space N)
(prinl / Tag ) ) ) )
(_xml2) ) )
(de _xml2 (Tok Decl In)
#(println Tok)
(cond
((not Tok)
(skip)
(unless (= (char))
(quit Bad XML start) )
(_xml2 (till /)))
((head '(? x m l) Tok)
(if Decl
(quit XML declaration too late)
# TODO check decl validity
(from ?)
(skip)
(unless (= (char))
(quit Bad XML element start) )
(_xml2 (till /) T)))
((head '(! - -) Tok)
(from --)
(unless In
(skip)
(unless (= (char))
(quit Bad XML element start) )
(_xml2 (till /) T)))
(T
(use X
(make
(link (intern (pack Tok)))
(let L
(make
(loop
(NIL (skip) (quit XML parse error 1))
(T (member @ '(/ )))
(NIL (setq X (intern (till = T
(char)
(unless (= \ (char))
(quit XML parse error 2 X) )
(link (cons X (pack (xmlEsc (till \)
(char) ) )
(if (= / (char))
(prog (char) (and L (link L)))
(link L)
(loop
(NIL (skip) (quit XML parse error 3 (pack Tok)))
(T (and (= (setq X (char))) (= / (peek)))
(char)
(unless (= Tok (till /))
(quit Unbalanced XML (pack Tok) ))
(char) )
(if (= X)
(and (_xml2 (till /) T T) (link @))
(link
(pack (xmlEsc (trim (cons X (till
^J)))
It can parse the following file:
?xml version=1.0?!--*- xml -*--
!-- comment 1 --
hi
!-- another comment --
bye123/bye
/hi
!-- comment 2 --
!-- last comment --
Is this mailing list the right place to decide such changes?
How does current decision making work?
Thanks,
Tomas
--
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]