|
Subject: Re: (dsssl) Turning a string into a sequence of character nodes From: Norman Walsh <ndw@xxxxxxxxxx> Date: Fri, 10 May 2002 17:27:52 -1000 |
/ Brandon Ibach <bibach@xxxxxxxxxxxxxx> was heard to say:
| (define (string->nodes s)
| (let ((doc (string-append "<literal><!DOCTYPE doc [ <!ELEMENT "
| "doc - - (#PCDATA)> ]><doc>" s "</doc>")))
| (children (node-property 'docelem (sgml-parse doc)))))
Thanks! I wound up with
(define (string->nodes s)
;; Escape XML characters...
(let* ((achars (string-replace s "&" "&#38;#38;"))
(bchars (string-replace achars "<" "&#38;#60;"))
(cchars (string-replace bchars ">" "&#38;#62;")))
(let ((doc (string-append "<literal><!DOCTYPE doc [ <!ELEMENT "
"doc - - (#PCDATA)> ]><doc>" cchars ";</doc>")))
(children (node-property 'docelem (sgml-parse doc))))))
so that markup characters in the string wouldn't cause the parser to
barf. This will still fail, I think, if the string contains characters
not in the character set of the SGML declaration in effect, but I'm
not sure what to do about that.
Be seeing you,
norm
--
Norman Walsh <ndw@xxxxxxxxxx> | Klein bottle for rent; enquire within.
http://nwalsh.com/ |
DSSSList info and archive: http://www.mulberrytech.com/dsssl/dssslist
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: (dsssl) Turning a string into a, Brandon Ibach | Thread | Re: (dsssl) Turning a string into a, Brandon Ibach |
| (dsssl) weirdness with caracter set, Holger Klawitter | Date | Re: (dsssl) Turning a string into a, Brandon Ibach |
| Month |