Message94074
ElementTree doesn't correctly serialize end-of-line characters (#xa,
#xd) in attribute values. Since bare end-of-line characters are
converted to #x20 by the parser according to the specification [1], such
characters that are represented as character references in the original
document must be serialized in the same form.
[1] http://www.w3.org/TR/xml11/#AVNormalize
### sample code
from xml.etree.ElementTree import ElementTree
from cStringIO import StringIO
# builder = ElementTree(file=StringIO("<foo>\x0d</foo>"))
# out = StringIO()
# builder.write(out)
# print out.getvalue()
out = StringIO()
ElementTree(file=StringIO(
'''<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE foo [
<!ELEMENT foo (#PCDATA)>
<!ATTLIST foo attr CDATA "">
]>
<foo attr=" test
test  test a "> </foo>
''')).write(out)
# should be "<foo attr=" test test test a ">\x0a</foo>
print out.getvalue()
out = StringIO()
ElementTree(file=StringIO(
'''<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE foo [
<!ELEMENT foo (#PCDATA)>
<!ATTLIST foo attr NMTOKENS "">
]>
<foo attr=" test
test  test a "> </foo>
''')).write(out)
# should be "<foo attr="test test test a">\x0a</foo>
print out.getvalue() |
|
Date |
User |
Action |
Args |
2009-10-15 06:21:30 | moriyoshi | set | recipients:
+ moriyoshi |
2009-10-15 06:21:30 | moriyoshi | set | messageid: <1255587690.83.0.0369111720877.issue7139@psf.upfronthosting.co.za> |
2009-10-15 06:21:29 | moriyoshi | link | issue7139 messages |
2009-10-15 06:21:28 | moriyoshi | create | |
|