classification
Title: XMLGenerator: nice elements
Type: feature request
Components: XML Versions: Python 2.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: gagenellina, panzi, vhata
Priority: normal Keywords: easy, patch

Created on 2007-10-27 13:33 by panzi, last changed 2008-05-10 18:37 by vhata.

Files
File name Uploaded Description Edit Remove
python-xml-sax-saxutils.zip panzi, 2007-10-27 13:33
xml.sax.saxutils.patch panzi, 2007-10-27 13:34
_xmlplus.sax.saxutils.patch panzi, 2007-10-27 13:35
xml.sax.saxutils.patch vhata, 2008-05-10 18:11
test.test_sax.py.patch vhata, 2008-05-10 18:12
short_empty_tag.patch vhata, 2008-05-10 18:37
Messages
msg56849 (view) Author: (panzi) Date: 2007-10-27 13:33
I modified xml.sax.saxutils.XMLGenerator,
_xmlplus.sax.saxutils.XMLGenerator, and
_xmlplus.sax.saxutils.LexicalXMLGenerator so that they do no longer
produce those
ugly close tags for empty elements, but use the short version. So instead of
<empty></empty> you get just <empty/>.  :) 

I used the version of saxutils.py that is shipped with python 2.5.1.
msg56850 (view) Author: (panzi) Date: 2007-10-27 13:34
patch for xml/sax/saxutils.py
msg56851 (view) Author: (panzi) Date: 2007-10-27 13:35
patch for _xmlplus.sax.saxutils.py
msg57202 (view) Author: Gabriel Genellina (gagenellina) Date: 2007-11-07 15:56
Some (ugly) parsers insist on <container></
container> when the element is not declared to 
be empty, so this should be optional (the 
default being generate <container/>)
msg66551 (view) Author: Jonathan Hitchcock (vhata) Date: 2008-05-10 18:11
The attached patch makes this new feature optional, by passing the
"empty_element_tag" option to the constructor.
msg66552 (view) Author: Jonathan Hitchcock (vhata) Date: 2008-05-10 18:12
I have also added some unit tests to test the feature with the option
turned on, and off - patch attached.
msg66556 (view) Author: Jonathan Hitchcock (vhata) Date: 2008-05-10 18:37
Acting on a comment (with which I agree) that the "empty_elements_tag"
wasn't such an obvious name, here's a (combined) patch which uses the
name "short_empty_elements" (which was my original gut-feeling idea for
the name, before I checked the W3C standard and found that they called
them "Empty-Elements tags") instead.
History
Date User Action Args
2008-05-10 18:37:25vhatasetfiles: + short_empty_tag.patch
messages: + msg66556
2008-05-10 18:12:35vhatasetfiles: + test.test_sax.py.patch
messages: + msg66552
2008-05-10 18:11:49vhatasetfiles: + xml.sax.saxutils.patch
nosy: + vhata
messages: + msg66551
2008-01-20 20:34:44christian.heimessetpriority: normal
keywords: + patch, easy
2007-11-07 15:56:55gagenellinasetnosy: + gagenellina
messages: + msg57202
2007-10-27 13:35:29panzisetfiles: + _xmlplus.sax.saxutils.patch
messages: + msg56851
2007-10-27 13:34:58panzisetfiles: + xml.sax.saxutils.patch
messages: + msg56850
2007-10-27 13:33:55panzicreate