473,385 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

newlines and sax.saxutils.quoteattr

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/pyt...ch/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: ed*******@charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Sep 19 '06 #1
2 1967
Edward K. Ream wrote:
- 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>

Sep 19 '06 #2
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
--------------------------------------------------------------------
Edward K. Ream email: ed*******@charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Sep 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Christopher Finke | last post by:
I have a site wherein the clients can update the individual pages by editing the text of that page in a <textarea>. Then, when the page is displayed, all of the newlines (\n) are converted to HTML...
4
by: Grant Edwards | last post by:
I'm using xml.sax to parse the "datebook" xml file generated by QTopiaDesktop. When I look at the xml file, some of the attribute strings have newlines in them (as they are supposed to). ...
2
by: chris.atlee | last post by:
It seems like functions such as xml.sax.saxutils.escape and unescape are generally useful, and not at all tied to the xml.sax module. Would it make sense to move them somewhere else, like to xml?...
1
by: chris | last post by:
Confused somewhat xml newbie. I'm trying to output xml with a CDATA section, using saxutils.XMLGenerator, but the output contains escaped '<' and '>' and '&' from the CDATA element. Shouldn't it...
6
by: dbee | last post by:
So I can't seem to urlencode a file with newlines ... it just gives me a series of T_STRING unexpected parse errors... cat job_description | while read file ; do php -r "echo...
1
by: dbee | last post by:
Hi, So I'm having a problem with disappearing newlines. I import the newlines from a file into my shell script fine. But then I process the text and the url_encode comes out the other end with...
0
by: skip | last post by:
*argh!* I hate XML! There, now that that's off my chest... I am trying to save Python code as attributes of an XML tag with xml.dom.minidom machinery. The code, predicatbly enough, contains...
1
by: HopfZ | last post by:
Not a question. I tested how two kinds of newlines (\n and \r\n) interact with three browsers: Fx (Firefox 2), Op (Opera 9), Ie (IE 7) (all three on Windows XP). Result: The string...
4
by: lihao0129 | last post by:
Hi, folks: I recently went through a strange problem with my Javascript code, say: I have a string variable which are from a 'textarea' element and I want to remove the trailing newlines inside...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.