Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17140

Re: Fixing the XML batteries

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.alphanet.ch!alphanet.ch!news.imp.ch!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'package,': 0.03; 'context': 0.04; 'python': 0.08; 'attributes,': 0.09; 'optionally': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'anyway': 0.09; 'converting': 0.15; 'cet': 0.16; 'doing,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'lines),': 0.16; 'received:mnet- online.de': 0.16; 'stripped': 0.16; 'subject:XML': 0.16; 'thanks,': 0.18; '>>>': 0.18; 'simpler': 0.18; '(which': 0.19; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'versions': 0.23; 'though.': 0.23; 'fine': 0.24; 'stefan': 0.24; 'code': 0.25; 'module': 0.26; 'function': 0.27; 'import': 0.27; 'pass': 0.29; 'matches': 0.29; 'class': 0.29; 'seem': 0.30; 'for,': 0.30; 'separately': 0.30; 'xml': 0.31; "didn't": 0.31; 'version': 0.32; 'quite': 0.32; 'typically': 0.32; 'implement': 0.32; 'header:User- Agent:1': 0.33; 'actually': 0.33; 'this.': 0.33; 'header:X -Complaints-To:1': 0.33; 'there': 0.33; 'to:addr:python-list': 0.34; 'too': 0.34; 'certain': 0.34; 'all.': 0.34; 'however,': 0.36; '8bit%:86': 0.37; 'depend': 0.37; 'skip:" 10': 0.37; 'but': 0.37; 'using': 0.38; 'received:org': 0.38; 'i.e.': 0.39; 'option': 0.39; 'received:de': 0.39; 'should': 0.39; 'to:addr:python.org': 0.40; 'worth': 0.61; 'your': 0.61; 'below': 0.63; 'you.': 0.63; 'here.': 0.66; 'glad': 0.68; 'skip:\xd0 20': 0.77; 'received:88.217': 0.84; 'standard,': 0.84; 'releases.': 0.91; 'old.': 0.97
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Stefan Behnel <stefan_ml@behnel.de>
Subject Re: Fixing the XML batteries
Date Tue, 13 Dec 2011 15:59:52 +0100
References <jbsfar$en7$1@dough.gmane.org> <CAKmKYaBid4c8Y0pe7txxZMk9+0WN8Hr5ZodS=HP05MdV-ysPhQ@mail.gmail.com> <4EE7425A.2090006@gmail.com> <jc7glm$j62$1@dough.gmane.org> <jc7ndj$5rn$1@dough.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host ppp-88-217-94-187.dynamic.mnet-online.de
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110921 Lightning/1.0b2 Thunderbird/3.1.15
In-Reply-To <jc7ndj$5rn$1@dough.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3599.1323788409.27778.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1323788409 news.xs4all.nl 6903 [2001:888:2000:d::a6]:37789
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17140

Show key headers only | View raw


Serhiy Storchaka, 13.12.2011 15:27:
> 13.12.11 14:32, Stefan Behnel написав(ла):
>> I stripped my name from the quoted context because I didn't say this.
>
> I am glad to hear this. ;)

It matches my opinion though.


>>> I use xml.dom.minidom for XML canonization and convertion:
>> Do you mean "canonicalisation"? I.e. C14N? That's not what the code
>> below is doing, not at all.
>
> No, only converting to certain textual representation. Converting entities
> to text (if possible), converting "'" to '"' for quoting, sorting
> attributes, etc.

Yes, that's what C14N is there for, typically used for cryptography, 
hashing, etc. However, MiniDOM doesn't implement that standard, so you're 
on your own here.


>>> How to do this with xml.etree.ElementTree?
>> In Python 2.7/3.2, ElementTree has support for C14N serialisation, just
>> pass the option method="c14n".
>
> Thanks, I will try this. But I need 2.6+ compatibility.

The ET module is actually quite short (<1700 lines), so you can just copy 
the Py2.7 version into your sources and optionally import it on older 
Python releases. Since you only seem to depend on the serialiser (which is 
worth using anyway because it is much faster in the Py2.7 version), older 
platform versions of cET should also work just fine with that module copy, 
so you can basically just import everything from xml.etree.cElementTree and 
use the ElementTree class and the tostring() function from your own local 
version if the platform version is too old.

Note that ET is also still available as a separately installable package, 
may or may not be simpler to use for you.

Stefan

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Fixing the XML batteries Stefan Behnel <stefan_ml@behnel.de> - 2011-12-13 15:59 +0100

csiph-web