CL Printing Strings for use in XML
Posted: Thu Dec 24, 2009 5:57 pm
Hello!
I am working on a project where (among other things) we are writing a list of pairs of values to be embedded in an xml document. Sometimes both members of the pair are symbols; and sometimes they are a symbol and a string. The overall lisp program is quite large. The example shown below is simplified to the essential problem area.
I have not yet found a successful way to write the string in a way that works for XML. So far, here is what I have:
Everythings works fine when both members of the pair are symbols.
The problem is that when the second item in the pair is a string, the output has double quotation marks which is not allowed in XML.
For example, if the pair consists of: buyer "stamps", then my output is:
... <slot name="buyer" value=""stamps""/> ...
My desired output in this case would instead be:
... <slot name="buyer" value=""stamps""/> ...
is there a straightforward way to do this?
Thanks
inexperienced
I am working on a project where (among other things) we are writing a list of pairs of values to be embedded in an xml document. Sometimes both members of the pair are symbols; and sometimes they are a symbol and a string. The overall lisp program is quite large. The example shown below is simplified to the essential problem area.
I have not yet found a successful way to write the string in a way that works for XML. So far, here is what I have:
Code: Select all
(defconstant *xml-print-pairs*
(formatter
"<chunk name=\"~S\">~:[ (~s)~;~*~]~%~@[~S~%~] <isa value=\"~S\"/>~%~:{ <slot name=\"~s\" value=\"~s\"/>~%~}</chunk>")
"compiled format string for printing chunks in xml format")
(format stream-out *xml-print-pairs* chunk-name my-pairs)
The problem is that when the second item in the pair is a string, the output has double quotation marks which is not allowed in XML.
For example, if the pair consists of: buyer "stamps", then my output is:
... <slot name="buyer" value=""stamps""/> ...
My desired output in this case would instead be:
... <slot name="buyer" value=""stamps""/> ...
is there a straightforward way to do this?
Thanks
inexperienced