[jdom-interest] Bug with Default Namespace

Thomas Koch Thomas.Koch at atlantec-es.com
Thu Nov 9 04:08:46 PST 2000


Rick,

coincidentally I encountered the same problem a few days ago.
I believe the problem is in Namespace. The patch that I applied
for that is:

*** Namespace.java.1.5	Fri Sep 29 09:14:07 2000
--- Namespace.java	Tue Nov  7 17:21:54 2000
***************
*** 181,185 ****

          // Return existing namespace if found
!         if (namespaces.containsKey(uri)) {
              return (Namespace)namespaces.get(prefix + "&" + uri);
          }
--- 181,185 ----

          // Return existing namespace if found
!         if (namespaces.containsKey(prefix + "&" + uri)) {
              return (Namespace)namespaces.get(prefix + "&" + uri);
          }

But as soon as this works, there is a problem in SAXBuilder: if you check,
you will notice that the availableNamespaces list grows according
to the number of instances, creating a substantial performance problem
on large XML files.
I have fixed that temporarily (see below), but I doubt
that it is the correct solution. The problem seems to be that
availableNamespaces is sometimes used like a Stack, and sometimes
like a incorrectly working Set. But I might be totally wrong
in my understanding of the code.

*** SAXBuilder.jdom-1.5x.java	Mon Oct 23 19:16:40 2000
--- SAXBuilder.jdom-1.5x-p1.java	Thu Nov  9 13:03:09 2000
***************
*** 749,754 ****

          // Remove the namespaces that this element makes available
! 	availableNamespaces.remove(element.getAdditionalNamespaces());
!
      }

--- 749,758 ----

          // Remove the namespaces that this element makes available
!         if (element.getAdditionalNamespaces() != null) {
!             availableNamespaces.remove(element.getAdditionalNamespaces());
!         }
!         if (element.getNamespace() != null) {
!             availableNamespaces.remove(element.getNamespace());
!         }
      }


Hope this helps,

Thomas



-----Original Message-----
From: jdom-interest-admin at jdom.org [mailto:jdom-interest-admin at jdom.org]On Behalf Of Rick Nucci
Sent: Thursday, November 09, 2000 04:19
To: jdom-interest at jdom.org
Subject: [jdom-interest] Bug with Default Namespace


Hello,

There is a bug in the latest codeset (I am using jdk1.3.0).  I am trying to build() an XML doc that in the root element has a
default namespace declared, like this:

<?xml version="1.0" encoding="UTF-8"?>
<Template xmlns="www.yahoo.com">
            <Application1 xmlns:xplt="www.xxxx.com" xmlns:xpl="www.xxxx.com" version="3.0">
                        <xpl:insertText />
                        <xplt:anyElement>
                                    <Name />
                        </xplt:anyElement>
            </Application1>
            <Application2 xmlns:xplt="www.xxxx.com" xmlns:xpl="www.xxxx.com" version="3.0">
                        <xpl:insertText />
                        <xplt:anyElement>
                                    <Name />
                        </xplt:anyElement>
            </Application2>
</Template>


After building this file and creating the org.jdom.Document object, All is fine, except the default namespace (in this case for
www.yahoo.com) is ignored, ie not present in the doc object.  When this same Document object is then output to a file using
XMLOutputter, the file is complete and correct.  The problem is somewhere in the build() process, but I have not been able to
determine the exact cause.

Regards,

Rick Nucci

______________________________________________

Rick Nucci
Partner, Boomi Inc.
(610) 834-8730
rick_nucci at boomi.com
http://www.boomi.com




More information about the jdom-interest mailing list