The following procedures serialize XML document records into character sequences. All are virtually identical except for the way that the character sequence is represented.
Each procedure will accept either an
xml-document record or any
of the other XML record types. This makes it possible to
write fragments of XML documents, although you should keep in
mind that such fragments aren't documents and won't generally be
accepted by any XML parser.
If the xml being written is an
xml-document record, the
write-xml-file will look for a
xml-declaration record and its
attribute. If the
encoding is a supported value, the output will
be encoded as specified; otherwise it will be encoded as
When an XHTML document record is written, named
XHTML characters are translated into their corresponding
entities. For example, the character `#\U+00A0' is written as
` '. In order for an XML document record to be
recognized as XHTML, it must have a DTD record that
satisfies the predicate
Write xml to port. Note that character encoding will only be done if port supports it.
Write xml to the file specified by pathname. Roughly equivalent to(define (write-xml-file xml pathname) (call-with-output-file pathname (lambda (port) (write-xml xml port))))
Convert xml to a wide string. No character encoding is used, since wide strings can represent all characters without encoding. Roughly equivalent to(define (xml->wide-string xml) (call-with-wide-output-string (lambda (port) (write-xml xml port))))