[cxml-devel] cxml:doctype function

Nunez Steve steve_nunez at yahoo.com
Sat Jun 20 00:06:25 UTC 2009


Thanks. What I am hoping for is a way to write multi-line comments. cxml:text doesn't seem to work outside elements.



________________________________
From: David Lichteblau <david at lichteblau.com>
To: Nunez Steve <steve_nunez at yahoo.com>
Cc: cxml-devel at common-lisp.net
Sent: Friday, June 19, 2009 7:33:53 PM
Subject: Re: [cxml-devel] cxml:doctype function

Quoting Nunez Steve (steve_nunez at yahoo.com):
> A follow-up question: Is there a way to emit a newline into the file?
> It would help in readability of some parts.

Unless the sink is in canonical mode (and canonical isn't the default
anymore in current cxml), newline characters in text are written
literally, so just write text including a newline.  Example:

CL-USER> (cxml:with-xml-output (cxml:make-string-sink)
           (cxml:with-element "test"
             (cxml:text (format nil "foo~%bar"))))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<test>foo
bar</test>"


That's for manual breaks.  If you were hoping for automatic indentation,
there's the :INDENTATION keyword argument:

CL-USER> (cxml:with-xml-output (cxml:make-string-sink :indentation 2)
           (cxml:with-element "outer"
             (cxml:with-element "inner"
               (cxml:text (format nil "foo~%bar")))))
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<outer>
  <inner>
    foo bar</inner>
</outer>"

The indentation support isn't very good though.  I use it only for
debugging purposes.  Also note that it reindents texts, removing the
explicit newline.


d.



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cxml-devel/attachments/20090619/a348a0f4/attachment.html>


More information about the cxml-devel mailing list