[XML-SIG] c14n and subset

Joshua Boverhof JRBoverhof at lbl.gov
Thu Oct 16 23:06:01 EDT 2003


Is this what you're trying to do?
-josh


$ python c14n_simple.py
<B dog="stoli" xmlns:a="urn:a" xmlns="urn:b" a:cat="gin"></B>
[boverhof at dahmer Canonicalize]$ !cat
cat c14n_simple.py
from xml.dom import minidom
from xml.dom.ext import c14n

str = """<a:A xmlns:a="urn:a" xmlns="urn:b">
  <B a:cat="gin" dog="stoli"/>
</a:A>"""
dom = minidom.parseString(str)
B_el = dom.getElementsByTagNameNS("urn:b", "B")

#print c14n.Canonicalize(dom, subset=B_el)
print c14n.Canonicalize(B_el[0])


$ python c14n_simple.py
<B dog="stoli" xmlns:a="urn:a" xmlns="urn:b" a:cat="gin"></B>




Keith Beattie wrote:

> So, after staring at c14n.py for far too long and filing a bug against 
> it (825115) (see thread titles "c14n attribute ordering problem?"), I 
> gave the subset arg of Canonicalize() a try.
>
> This doesn't exibit #825115 but does have another problem, it doesn't 
> include the non-xmlns attributes.  For example:
>
> $ cat c14n_simple.py
> from xml.dom import minidom
> from xml.dom.ext import c14n
>
> str = """<a:A xmlns:a="urn:a" xmlns="urn:b">
>   <B a:cat="gin" dog="stoli"/>
> </a:A>"""
> dom = minidom.parseString(str)
> B_el = dom.getElementsByTagNameNS("urn:b", "B")
> print c14n.Canonicalize(dom, subset=B_el)
>
> $ python c14n_simple.py
> <B xmlns="urn:b" xmlns:a="urn:a"></B>
>
> I was expecting:
> <B xmlns="urn:b" xmlns:a="urn:a" dog="stoli" a:cat="gin"></B>
>
> Any ideas on what might be wrong?
>
> ksb
>
>
> _______________________________________________
> XML-SIG maillist  -  XML-SIG at python.org
> http://mail.python.org/mailman/listinfo/xml-sig







More information about the XML-SIG mailing list