How to say xml_encode not to output <?xml version="1.0" encoding="utf-8"?> ?

5 views
Skip to first unread message

Luis Miguel Morillas

unread,
May 12, 2011, 1:13:44 PM5/12/11
to akar...@googlegroups.com
I want the output string not to have the header <?xml version="1.0"
encoding="utf-8"?> . What parameter must I use to configure xml_encode
for it?

Saludos,

-- luismiguel

Uche Ogbuji

unread,
May 13, 2011, 5:40:20 PM5/13/11
to akar...@googlegroups.com
omit_xml_declaration = True


--
You received this message because you are subscribed to the Google Groups "Akara Developers" group.
To post to this group, send email to akar...@googlegroups.com.
To unsubscribe from this group, send email to akara-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akara-dev?hl=en.




--
Uche Ogbuji                       http://uche.ogbuji.net
Weblog: http://copia.ogbuji.net
Poetry ed @TNB: http://www.thenervousbreakdown.com/author/uogbuji/
Founding Partner, Zepheira        http://zepheira.com
Linked-in: http://www.linkedin.com/in/ucheogbuji
Articles: http://uche.ogbuji.net/tech/publications/
Friendfeed: http://friendfeed.com/uche
Twitter: http://twitter.com/uogbuji
http://www.google.com/profiles/uche.ogbuji

Luis Miguel Morillas

unread,
May 13, 2011, 6:17:23 PM5/13/11
to akar...@googlegroups.com
Ok. But it's not a direct param:

doc.xml_encode('omit_xml_declaration=True')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/lm/entorno_iaaa/lib/python2.7/site-packages/amara/writers/__init__.py",
line 151, in _xml_encode
_xml_write(N, writer, stream, encoding, **kwargs)
File "/home/lm/entorno_iaaa/lib/python2.7/site-packages/amara/writers/__init__.py",
line 128, in _xml_write
writer_class = lookup(writer)
File "/home/lm/entorno_iaaa/lib/python2.7/site-packages/amara/writers/__init__.py",
line 101, in lookup
raise ValueError("Unknown printer class %r" % printer_name)
ValueError: Unknown printer class 'omit_xml_declaration=True'

I think I must use an intermediate xmlprinter class, don't I?


I tested with it before:

doc.xml_encode('html')
'<a></a>'
doc.xml_encode('xml')
'<?xml version="1.0" encoding="UTF-8"?>\n<a/>'


Saludos,

-- luismiguel


2011/5/13 Uche Ogbuji <uc...@ogbuji.net>:

Uche Ogbuji

unread,
May 13, 2011, 9:17:53 PM5/13/11
to akar...@googlegroups.com
No that's the way it's supposed to work:

doc.xml_encode(omit_xml_declaration=True)

Note: that should not be a string, as you had it.

But above, correct code doesn't work, either, which is a bug.  It might take a bit of entangling, unfortunately.

--Uche
Reply all
Reply to author
Forward
0 new messages