#47 NamespaceSupport.java prefixes

SAX2_r2_(2.0.1)
closed-rejected
nobody
5
2003-05-29
2002-08-28
Anonymous
No

This may or may not be a bug and the patch I'm posting
may or may not be a fix. I've received the "can't
declare any more prefixes in this context" exception in
very weird circumstances when running Apache FOP, Axis
and JBuilder. I did not have the time to read all of
the SAX code through and understand what was going
on...always a recipe for disaster...but it came down to
these line 544 of NamespaceSupport.java:

if (!declsOK)
throw new IllegalStateException (
"can't declare any more prefixes in this
context");

The exception was being thrown on a "" prefix when
declsOK was false. I made a modification to stop this
behaviour as shown below:

if(prefix.length()>0)
{
if (!declsOK)
{
throw new IllegalStateException (
"can't declare any more prefixes in
this context");
}
}
else if(!declsOK)
{
declsOK = true;
}

It seemed to fix things and I've had no problems but by
making changes and not fully understand the code it
could potentially wreak havoc. I found no JUnit test
cases to run as part of the source code download so I
could really test this change...hence I'm posting this
'bug'.

Nonetheless, Axis and FOP are working for me...

So, is this bug and my change valid or have I
potentially broken my copy of SAX?

-sjb

Discussion

  • David Brownell
    David Brownell
    2003-05-29

    Logged In: YES
    user_id=44117

    Potentially broken your application code. The
    XML Namespaces code only allows contexts
    to be defined in a few places, between starting
    a new tag and the '>' that marks the end of
    that tag and the start of its children.

    It's likely some of your code was misusing
    the NamespaceSupport code, or equivalently
    was relying on bugs in early versions.

     
  • David Brownell
    David Brownell
    2003-05-29

    • status: open --> closed-rejected