[XML-SIG] c14n and subset
KSBeattie at lbl.gov
Fri Oct 17 03:02:21 EDT 2003
Joshua Boverhof wrote:
> Is this what you're trying to do?
> #print c14n.Canonicalize(dom, subset=B_el)
> print c14n.Canonicalize(B_el)
> $ python c14n_simple.py
> <B dog="stoli" xmlns:a="urn:a" xmlns="urn:b" a:cat="gin"></B>
Well, no, because that isn't canonical form. :/
Canonical form for this would be:
<B xmlns="urn:b" xmlns:a="urn:a" dog="stoli" a:cat="gin"></B>
c14n ordering of attributes is:
1st) the default namespace declaration ('xnlms="<whatever>"') first
2nd) namespace declarations, sorted by prefix (the part after the ':')
3rd) unqualified attributes, sorted by name
4th) qualified attributes, sorted by namespace URI
I initially tried what you suggest which led me to filing bug #825115
(which at the time I thought was only a violation of my rule #1, but it
appears to be a bit more). After using the subset arg of
Canonicalize(), it follows rule #1, but appears to drop attributes under
rules 3 & 4.
Looking at the code in c14n.py it appears that all the proper logic is
there (and the use of subset getting rule #1 right is encouraging), but
honestly my head is spinning with all it's recursion and terse comments.
I'm hoping that perhaps c14n.py can do what I need (an exc c14n of an
xpath subset of a doc) and that my initial test of using a sub-element
as the lone arg to Canonicalize (my filed bug) is a known limitation.
More information about the XML-SIG