newlines and sax.saxutils.quoteattr

E

Edward K. Ream

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
 
F

Fredrik Lundh

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

http://www.w3.org/TR/REC-xml/#AVNormalize
- 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' ?

perhaps. a really good idea would be store free-format text in
elements, not attributes, but I guess it's too late to fix OPML.

</F>
 
E

Edward K. Ream

Thanks, Fredrik, for the reference to the attribute normalization algorithm.
I guess it's too late to fix OPML.

It's too late for OPML 1. I'll check with Dave Winer about OPML 2.

Edward
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top