newlines and sax.saxutils.quoteattr

Edward K. Ream edreamleo at charter.net
Tue Sep 19 11:10:21 EDT 2006


Hello all,

I recently ran across a situation in which sax.saxutils.quoteattr did not 
work as I expected.  I am writing Leo outlines as opml files
http://en.wikipedia.org/wiki/OPML
which forces me to write python code in xml attributes rather than xml 
elements (as is done in .leo files).

The problem is that the sax parser I am using ignores newlines in 
attributes.  After reading the thread at:

http://mail.python.org/pipermail/python-list/2006-March/332307.html

I was able to work around the problem by converting newlines to '
\n'. 
This makes the opml file as readable as possible (since the attributes 
contains newlines in addition to the character reference 
  In addition, 
the sax parser seems happy.

My questions:

- Does anyone know whether this is guaranteed to be a general solution? That 
is, are sax parsers *obliged* to ignore newlines in attributes?

- If sax parsers are indeed obliged to ignore newlines in attributes, would 
it be a good idea to (optionally?) have sax.saxutils.quoteattr perform the 
substitution of newlines to '
\n' ?

Thanks.

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edreamleo at charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------





More information about the Python-list mailing list