[jdom-interest] DOMOutputter, xml security, getLocalName, and createElement

Kerry Ward kward at tybera.com
Mon Aug 12 16:02:21 PDT 2002

I am having a problem with using the results of DOMOutputter.  I needed to get the canonicalized version of a portion of a document I create using JDOM, so I wrote the following code that uses Apache's XML Security package.

         DOMOutputter domOutputter = new DOMOutputter();
            Canonicalizer c14n =
         byte[] canonicalizedData = c14n.canonicalizeSubtree(domOutputter.output(wrapperElem));

This is failing in the Apache XML Security package when it tries to use the local name of an attribute.  attrNode.getLocalName() returns null, but attrNode.getNodeName() returns the attributes name.

I researched a bit and found in the Xalan documentation this note concerning getLocalName
public java.lang.String getLocalName()
  Returns the local part of the qualified name of this node. 
  For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null. 
    DOM Level 2 

I looked in the code and sure enough, DOMOutputter is using createElement which is a DOM level 1 method.

Is DOMOutputter meant to be only DOM Level 1 compliant, or is this just an oversight?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020812/ca1c9ca2/attachment.htm

More information about the jdom-interest mailing list