Discussion:
Case-sensitive XML
Ken Harris
2007-11-12 00:16:04 UTC
Permalink
Hi!

I'm having trouble outputting case-sensitive XML using cl-who. The
*downcase-tokens-p* variable claims to be the answer, but it only
controls whether the output is all-upper-case or all-lower-case:

(setq *downcase-tokens-p* nil)
(with-html-output-to-string (s) (:twoWords))
=> "<TWOWORDS/>"

(setq *downcase-tokens-p* t)
(with-html-output-to-string (s) (:twoWords))
=> "<twowords/>"

I don't get how this is supposed to help with case-sensitive XML:
keywords (like all symbols) are case-folded by the CL reader before
cl-who sees them, no? :twoWords => :TWOWORDS. To support generation
of XML with mixedCase tags or attributes, I would think that cl-who
would need to allow strings where it allows only keywords now.

Or maybe I'm just completely missing something, because the question
that prompted the creation of *downcase-tokens-p* was a camelCase
attribute.

Can cl-who support mixedCase tags/attributes? Or if it's as simple as
changing (keywordp x) to (or (keywordp x) (stringp x)), would such a
patch be well-received?

thanks!


- Ken
Osei Poku
2007-11-12 00:27:58 UTC
Permalink
Post by Ken Harris
Hi!
I'm having trouble outputting case-sensitive XML using cl-who. The
*downcase-tokens-p* variable claims to be the answer, but it only
(setq *downcase-tokens-p* nil)
(with-html-output-to-string (s) (:twoWords))
=> "<TWOWORDS/>"
You must quote the symbol with |symBol|. ie

(setq *downcase-tokens-p* nil)
(with-html-output-to-string (s) (:|twoWords|))
=> "<twoWords/>"

OR

=> "<twoWords></twoWords>"
Post by Ken Harris
(setq *downcase-tokens-p* t)
(with-html-output-to-string (s) (:twoWords))
=> "<twowords/>"
keywords (like all symbols) are case-folded by the CL reader before
cl-who sees them, no? :twoWords => :TWOWORDS. To support generation
of XML with mixedCase tags or attributes, I would think that cl-who
would need to allow strings where it allows only keywords now.
Or maybe I'm just completely missing something, because the question
that prompted the creation of *downcase-tokens-p* was a camelCase
attribute.
Can cl-who support mixedCase tags/attributes? Or if it's as simple as
changing (keywordp x) to (or (keywordp x) (stringp x)), would such a
patch be well-received?
thanks!
- Ken
_______________________________________________
cl-who-devel site list
http://common-lisp.net/mailman/listinfo/cl-who-devel
--
Osei Poku
PhD Student, ECE
Carnegie Mellon University

412.268.2687 (work)
Ken Harris
2007-11-12 01:16:04 UTC
Permalink
Hi Osei,
Post by Osei Poku
You must quote the symbol with |symBol|. ie
Ah! That will do it.

I guess that means I need to (setq *downcase-tokens-p* nil) and then
||-escape every tag, which seems unfortunate, but I don't think
there's anything cl-who could do to make it nicer.

Thanks for the super-prompt response.


- Ken
Osei Poku
2007-11-12 01:22:32 UTC
Permalink
Post by Ken Harris
Hi Osei,
Post by Osei Poku
You must quote the symbol with |symBol|. ie
Ah! That will do it.
I guess that means I need to (setq *downcase-tokens-p* nil) and then
||-escape every tag, which seems unfortunate, but I don't think
there's anything cl-who could do to make it nicer.
Maybe you could play with the reader case settings so that it doesn't
upcase symbols by default.

look into READTABLE-CASE

http://www.lisp.org/HyperSpec/Body/acc_readtable-case.html
Post by Ken Harris
Thanks for the super-prompt response.
Glad to help :)
Post by Ken Harris
- Ken
_______________________________________________
cl-who-devel site list
http://common-lisp.net/mailman/listinfo/cl-who-devel
--
Osei Poku
PhD Student, ECE
Carnegie Mellon University

412.268.2687 (work)
Loading...