[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xml collection: how to insert arbirtrary xml code



On Mon, Feb 28, 2000 at 07:34:13PM +0100, Marco Maggesi wrote:
> 
> how one can insert xml/html code literally using the xml
> collection?
> 
> example 1: split the code in multiple lines using
>   write-xml/conten i.e. insert a newline character where I
>   need.

display-xml/content inserts newlines and whitespace indenting as it sees
fit, which is not always technically correct if whitespace is significant
in your xml language.

To produce newlines in the output generated by write-xml/content, you need
to put newline characters in the strings within the tree of xml content
before you write it out, just like any other character.
> 
> example 2: insert xml/html code verbatim or include xml code
>   from a separate file.
> 
> thank you
> marco

The standard plt-scheme reader that processes program text does not recognize
xml syntax.  If you want to include litteral xml code with a relatively high
ratio of elements to text, I recommend you use Xexpressions.  The result
will be shorter since you don't have to write down end tags everwhere.  Also,
the DrScheme environment will match ()'s for you.  If your xml document
contains mostly text within a few elements, then you may wish to use xml
syntax in a separate file.  Then use something like this:
(define my-xml-stuff (call-with-input-file "constant-xml-stuff.xml" read-xml))


Paul