#3 NamespaceSupport caching problem

javadoc (14)

Reported by Michael Kay 2001-04-16:

This appears to be a bug in the
org.xml.sax.helpers.NamespaceSupport module,
one of the "helper" routines that comes in the SAX2
distribution! It's doing
some caching of results which is apparently defeated by
using the same QName
in a child and a parent element, with different
namespace declarations. I
haven't yet worked out why changing the order of the
namespace declarations
affects the outcome, though.


  • Nobody/Anonymous

    Logged In: NO

    Here's a more detailed explanation.

    So long as the user of NamespaceSupport follows the rule
    that all namespace declarations on an element are declared
    (using declarePrefix()) before any QNames for that context
    are resolved (using processName()), there is no problem.
    However, ParserAdapter doesn't follow this protocol. It
    processes the attributes on an element in the order they
    occur. If an attribute foo:a is encountered before the
    namespace declaration xmlns:foo="namespace.one", then it
    relies on processName() returning a "namespace undeclared"
    response, and if this occurs it tries again when all
    attributes (and therefore namespace declarations) have been
    processed. However, if the parent element has a namespace
    declaration xmlns:foo="namespace.two", then the "namespace
    undeclared" response doesn't happen, and the prefix foo is
    wrongly bound to "namespace.two".

    The bug is that NamespaceSupport relies on namespaces being
    declared before any attempt is made to process names, but
    this protocol isn't documented, and client code that works
    in the way ParserAdapter does will bind a prefix to the
    wrong namespace.

    Mike Kay

  • Nobody/Anonymous

    Logged In: NO

    Actually I think this is the same bug as 441055

    Mike Kay

  • Anonymous - 2001-07-31
    • labels: 340835 --> javadoc
  • Anonymous - 2001-07-31

    Logged In: YES

    OK, since 441055 is really two bugs in one,
    I'll treat this bug as the "NamespaceSupport
    declare-before-use protocol undocumented"
    bug. (Javadoc only.)

  • Anonymous - 2001-08-01
    • assigned_to: nobody --> dbrownell
    • status: open --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks