> All,
>
> a question to the c14 gurus on the list.
>
> I set up an Element node and set the default namespace
> to "" using the following code:
>
>    elem.setAttributeNS(WSConstants.XMLNS_NS, "xmlns", "");
>
> This seems to work.
>
> The element is c14n'ed using the following code:
>
>    XMLUtils.circumventBug2650(elem);
>
>    /*
>     * C14n with specified algorithm. According to WSS Specification.
>     * c14n algo is: c14n ExclOmitComments
>     */
>     buf = canon.canonicalizeSubtree(doc, "#default");
>
> After this the xmlns="" is gone, at least when I convert the
> buf to String and print it I don't see a xmlns="" at the
> elements.
>
> What is wrong with the above?
>
>
> Regards,
> Werner
>

First, what version of xml-sec are you using? If you are using the CVS you
don't need the circumventBug2650 for subtree c14n.
Anyway, In the exclusive the inclusive namespaces are treated like it
would be in the inclusive and in the inclusive spec the rule for writting
xmlns="" is:
<cite>
    * the element E that owns the axis is in the node-set
    * The nearest ancestor element of E in the node-set has a default
namespace node in the node-set (default namespace nodes always have
non-empty values in XPath)
The latter condition eliminates unnecessary occurrences of xmlns="" in the
canonical form since an element *only receives* an xmlns="" *if its
default namespace is empty and if it has an immediate *parent* in the
canonical form that has a *non-empty* default namespace*. To finish
processing L, simply process every namespace node in L, except omit
namespace node with local name xml, which defines the xml prefix, if its
string value is http://www.w3.org/XML/1998/namespace.
</cite>

So the xmlns="" will be removed if there is no other xmlns="X" definition
previously.

Reply via email to