Exclusive C14N (Was: Minutes of 2001-07-30 Teleconf)

At 14:31 7/30/2001, Joseph M. Reagle Jr. wrote:
>ACTION Reagle: write proposal akin to:

I've implemented [1] the proposal by creating an additional function _utilized that returns true for a given namespace node in an element (that is in the subset) if:
 1. It's in the unsuppressedPrefixList
 2. The element node.prefix is equal to the nsnode prefix.
 3. Any attribute prefix is equal to the nsnode prefix.
Then I add another conditional to the decision to render to see if it's been utilized. This is on the same order of magnitude as inclusive (an extra function call with 3 conditionals and a loop through the attributes), but doesn't require any look ahead in the document. It also keeps namespace declarations closer to where they're used.

[1] http://dev.w3.org/cvsweb/2001/xmlsec-python/c14n.py?rev=1.10&content-type=text/x-cvsweb-markup

The following examples are evaluated with
  '(//. | //@* | //namespace::*)[ancestor-or-self::e7]'
over a variant of example 3.

<!DOCTYPE doc [<!ATTLIST e9 attr CDATA "default">]>
<doc xmlns:foo="http://www.bar.org">
   <e1   />
   <e2   ></e2>
   <e3    name = "elem3"   id="elem3"    />
   <e4    name="elem4"   id="elem4"    ></e4>
   <e5 a:attr="out" b:attr="sorted" attr2="all" attr="I'm"
       xmlns:b="http://www.ietf.org" 
       xmlns:a="http://www.w3.org"
       xmlns="http://example.org"/>
   <e6 xmlns="" xmlns:a="http://www.w3.org">
       <e7 xmlns="http://www.ietf.org">
           <e8 xmlns="" xmlns:a="http://www.w3.org" a:foo="bar">
               <e9 xmlns="" xmlns:a="http://www.ietf.org"/>
           </e8>
       </e7>
   </e6>
</doc>

The inclusive canonical form is (note e7 exhibits xmlns:foo, and e9 exhibits xmlns:a):

<e7 xmlns="http://www.ietf.org" xmlns:a="http://www.w3.org" xmlns:foo="http://ww
w.bar.org">
           <e8 xmlns="" a:foo="bar">
               <e9 xmlns:a="http://www.ietf.org" attr="default"></e9>
           </e8>
       </e7>

The exclusive canonical form is (no xmlns:foo):

<e7 xmlns="http://www.ietf.org">
           <e8 xmlns="" xmlns:a="http://www.w3.org" a:foo="bar">
               <e9 attr="default"></e9>
           </e8>
       </e7>

If I remove the attribute a:foo, and instead qualify element e8:
             <a:e8 xmlns="" xmlns:a="http://www.w3.org">

The exclusive canonical form is:

<e7 xmlns="http://www.ietf.org">
           <a:e8 xmlns:a="http://www.w3.org">
               <e9 xmlns="" attr="default"></e9>
           </a:e8>
       </e7>

-- 
Joseph Reagle Jr.                 http://www.w3.org/People/Reagle/
W3C Policy Analyst                mailto:reagle@w3.org
IETF/W3C XML-Signature Co-Chair   http://www.w3.org/Signature
W3C XML Encryption Chair          http://www.w3.org/Encryption/2001/

Received on Monday, 30 July 2001 18:36:49 UTC