473,657 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

newlines and sax.saxutils.qu oteattr

Hello all,

I recently ran across a situation in which sax.saxutils.qu oteattr 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.qu oteattr perform the
substitution of newlines to ' \n' ?

Thanks.

Edward
--------------------------------------------------------------------
Edward K. Ream email: ed*******@chart er.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------
Sep 19 '06 #1
2 1985
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.qu oteattr 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*******@chart er.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
4552
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 line breaks (<br />). However, I have come across some instances where I do not want to convert the newlines, such as the following: <table> <tr> .... </tr>
4
2480
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). However, when xml.sax passes the attributes to my startElement() method the newlines seem to have been deleted. How do I get the un-munged element attribute values?
2
1458
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? I ask because it just took me 20 minutes to figure out how to escape entities in python. It's not obvious that this functionality should be buried 3 modules deep. Cheers, Chris
1
3421
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 be spit out intact? Here's code and output: from xml.sax import saxutils import sys handler = saxutils.XMLGenerator(sys.stdout)
6
2619
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 urlencode('$file');" ; done > job_description_encoded && URL_ENCODED_DESCRIPTION=`cat job_description_encoded` .... this takes in a job_description file and outputs a file with alot of errors in the text ... ?
1
1800
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 linefeeds intact but no newlines. Also any single quotes in my file give me a T_STRING unexpected error in my output ... even though I'm using rawurlencode(). I've tried escaping them in my text but no luck there.
0
1381
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 newlines. If I do nothing to my program text, upon output I get XML which looks like this: <SomeTag text="def _f(): return 3 "/>
1
11997
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 'A\nB\r\nC' contains both forms of newlines.
4
22320
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 the string. I am using something like the following: var txt = textarea_element.value.replace(/\n*$/, ''); But this replaced only the last newline(by changing '' to 'K', and
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.